设置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. Oracle数据库将varchar类型的字段改为clob类型

    alter table pwlp_accuse_info modify INSTRUCTION_STYLE long; alter table pwlp_accuse_info modify INST ...

  2. 以快板之名说Android 应用程序电源管理

    当里个当,当里个当.Android开发UE(用户体验)为导向,首要任务便是省电量. 当里个当,当里个当.有一设备立足于墙边,这个设备唤固定电话.你的app造成这样,用户很快把你弃墙角.你咆哮耗电奈何与 ...

  3. JAVA-开发IDE版本

    Eclipse发布的完整列表包括: Neon, June 22, 2016 Mars, June 24, 2015 Luna, June 25, 2014 Kepler, June 26, 2013 ...

  4. free的说明

    http://www.cnblogs.com/peida/archive/2012/12/25/2831814.html

  5. 转载:Unicode和Utf-8有何区别 转载自知乎 原文作者不详

    作者:于洋链接:https://www.zhihu.com/question/23374078/answer/69732605来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出 ...

  6. PHP开发框架比较

    PHP开发框架比较 Laravel 是一个简单优雅的 PHP WEB 开发框架,将你从意大利面条式的代码中解放出来.通过简单.优雅.表达式语法开发出很棒的 WEB应用!但是通过使用我们发现Larave ...

  7. GitHub万星项目:黑客成长技术清单

    最近有个GitHub项目很火,叫"Awesome Hacking",这个项目是由Twitter账号@HackwithGithub 维护,喜欢逛Twitter的安全爱好者应该了解,在 ...

  8. 使用com.jayway.jsonpath.JsonPath包进行JSON的快速解析、设置值需要注意的性能提升方法

    一.包地址 1.Maven:http://mvnrepository.com/artifact/com.jayway.jsonpath/json-path <!-- https://mvnrep ...

  9. Spark的运行模式(2)--Yarn-Cluster和Yarn-Client

    3. Yarn-Cluster Yarn是一种统一资源管理机制,可以在上面运行多种计算框架.Spark on Yarn模式分为两种:Yarn-Cluster和Yarn-Client,前者Driver运 ...

  10. Wrong FS: hdfs://xxx/xxx expected: file:///

    Eclipse调用HDFS API上传文件时出现了如下错误: Exception in thread "main" java.lang.IllegalArgumentExcepti ...