设置UIscrollview的背景代码

- (UIImage *) ImageWithColor: (UIColor *) color frame:(CGRect)aFrame
{
UIGraphicsBeginImageContext(aFrame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, aFrame); UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
   UIImage *image=[self ImageWithColor:[UIColor colorWithRed:/255.0f green:/255.0f blue:/255.0f alpha:] frame:self.view.bounds];

   image= [image stretchableImageWithLeftCapWidth:image.size.width*0.5f topCapHeight:image.size.height*0.5f];
UIImageView *imageview=[[UIImageView alloc] initWithImage:image];
[scrollview addSubview:imageview];

动态生成控件
//封装UILabel
+(UILabel*)LabWithFrame:(CGRect)_rect
text:(NSString*)aText
textColor:(UIColor*)aColor
textAlign:(NSTextAlignment)aAlign
font:(UIFont*)aFont{
UILabel *lab = [[[UILabel alloc] initWithFrame:_rect] autorelease];
lab.backgroundColor = [UIColor clearColor];
if ([aText length] > )
lab.text = aText;
if (aColor)
lab.textColor = aColor;
if(aAlign)
lab.textAlignment = aAlign;
if (aFont)
lab.font = aFont;
return lab;
}
//文本框
+(UITextField*)TextFieldWithFrame:(CGRect)_rect
target:(id)target
text:(NSString*)aText
textColor:(UIColor*)aTextColor
textAlign:(NSTextAlignment)aAlign
placeHolder:(NSString*)holder
clearMode:(UITextFieldViewMode)aViewMode
{
UITextField *textField = [[[UITextField alloc] initWithFrame:_rect] autorelease];
textField.backgroundColor = [UIColor clearColor];
textField.delegate = target; if (aAlign)
textField.textAlignment = aAlign;
if ([aText length] > )
textField.text = aText;
if (aTextColor)
textField.textColor = aTextColor;
if (aViewMode)
textField.clearButtonMode = aViewMode;
if ([holder length] > )
textField.placeholder = holder;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; return textField;
}

    CGRect viewRect=self.view.bounds;
CGRect bRec,ftRec=self.view.bounds;
ftRec=UIEdgeInsetsInsetRect(viewRect, UIEdgeInsetsMake(Kpadding, Kpadding, Kpadding, Kpadding)); for (int i=; i<self.mydata.count; i++) { Person *p=self.mydata[i];
//得到每一行 ,每行50的距离分割
CGRectDivide(ftRec, &bRec, &ftRec, 50, CGRectMinYEdge);

//得到padding的巨鹿
CGRect lbRect=UIEdgeInsetsInsetRect(bRec, UIEdgeInsetsMake(, , , kLbWidth)); //得到label的值
UILabel *label=[UILabel LabWithFrame:lbRect text:p.name textColor:[UIColor blackColor] textAlign:NSTextAlignmentRight font:[UIFont systemFontOfSize:]];
[self.view addSubview:label];
[label release]; CGRect txtRect=UIEdgeInsetsInsetRect(bRec, UIEdgeInsetsMake(Kpadding, lbRect.size.width+Kpadding, 0, 0)); UITextField *txtField=[UITextField TextFieldWithFrame:txtRect target:self text:p.desc textColor:[UIColor blackColor] textAlign:NSTextAlignmentLeft placeHolder:nil clearMode: UITextFieldViewModeWhileEditing];
txtField.borderStyle=UITextBorderStyleRoundedRect;
[self.view addSubview:txtField];
[txtField release];
}

TableView背景设置



UIImageView *tableBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"XXX.png"]];
[yourTable setBackgroundView:tableBg];
[tableBg release];

 

ios中键盘处理(二)的更多相关文章

  1. IOS中键盘隐藏几种方式

    在ios开发中,经常需要输入信息.输入信息有两种方式: UITextField和UITextView.信息输入完成后,需要隐藏键盘,下面为大家介绍几种隐藏键盘的方式. <一> 点击键盘上的 ...

  2. iOS中键盘的收起

    在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法之外,还有另外三种方法: 重载UIViewController中的touchesBegin方 ...

  3. ios中键盘处理源码

      1:先分别设置各个文本框的键盘类型(inputview)-->在特定键盘中textediting中禁用输入. 2:然后递归绑定各个键盘的工具条(inputaccessview).并且个各个控 ...

  4. H5页面IOS中键盘弹出导致点击错位的问题

    IOS在点击输入框弹出键盘  键盘回缩 后 定位没有相应改变  还有  textarea 也会弹出键盘 $("input").blur(function() { console.l ...

  5. ios 中的构造方法(二)

    在之前有简单介绍了构造方法的结构,以及构造方法的作用,那么我们现在来讨论一下: 对象的创建分为两步:+ alloc 分配内存空间和 -init 进行初始化 那么在继承自 NSObject 的类当中,我 ...

  6. ios中键盘处理适合ipad 和iphone

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UI ...

  7. ios 中键盘被遮挡解决方案

    1.当view是非可以滚动的view时, // 添加对键盘的通知 - -(void)viewDidLoad{ [[NSNotificationCenter defaultCenter] addObse ...

  8. ios 中生成二维码和相册中识别二维码

    iOS 使用CIDetector扫描相册二维码.原生扫描 原生扫描 iOS7之后,AVFoundation让我们终于可以使用原生扫描进行扫码了(二维码与条码皆可)AVFoundation可以让我们从设 ...

  9. IOS中input键盘事件支持的解决方法

    欢迎大家去我的网站详细查看http://genghongshuo.com.cn/ IOS中input键盘事件keyup.keydown.等支持不是很好, 用input监听键盘keyup事件,在安卓手机 ...

随机推荐

  1. Hadoop vs Spark性能对比

    http://www.cnblogs.com/jerrylead/archive/2012/08/13/2636149.html Hadoop vs Spark性能对比 基于Spark-0.4和Had ...

  2. Window配置Redis环境和简单使用

    一.关于Redis Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理.它支持字符串.哈希表.列表.集合.有序集合,位图,hyperloglogs等数据 ...

  3. 下周二推出“音视频技术WebRTC初探”公开课,欢迎捧场!

     下周二推出"音视频技术WebRTC初探"公开课,欢迎捧场! 公开课课程链接:http://edu.csdn.net/huiyiCourse/detail/90 课程的解说资料 ...

  4. SharePoint中Rating相关的字段。

      From: https://sharepoint.stackexchange.com/questions/194197/how-to-manipulate-likeby-nooflikes-rat ...

  5. KDiff

    BeyondCompare是收费的,用了一段时间不能用了.找到一个 KDiff做对比工具,也很好用. 在这里下载: http://sourceforge.net/projects/kdiff3/fil ...

  6. nodejs发送请求

    const https = require('https'); var options = { hostname: 'registry.yarnpkg.com', port: 443, path: ' ...

  7. [Functional Programming] Using JS, FP approach with Arrow or State Monad

    Using Naive JS: const {modify, get} = require('crocks/State'); const K = require('crocks/combinators ...

  8. eclipse启动错误:java.lang.NoClassDefFoundError: org/eclipse/core/resources/IContainer

    转自:http://blog.csdn.net/niu_hao/article/details/9332521 eclipse启动时报错如下:java.lang.NoClassDefFoundErro ...

  9. JavaScript 从闭包可以做什么开始,将有助于理解闭包

    本文内容 函数内部访问全局变量 函数外部不能直接访问局部变量 函数外部访问局部变量 保护私有成员 持久性 模块化 抽象性 闭包是 JavaScript 的重要特性,非常强大,可用于执行复杂的计算,可并 ...

  10. 通过项目逐步深入了解Mybatis<一>

    Mybatis Mybatis 和 SpringMVC 通过订单商品案例驱动 官方中文地址:http://www.mybatis.org/mybatis-3/zh/ 官方托管地址:https://gi ...