ios中键盘处理(二)
设置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中键盘处理(二)的更多相关文章
- IOS中键盘隐藏几种方式
在ios开发中,经常需要输入信息.输入信息有两种方式: UITextField和UITextView.信息输入完成后,需要隐藏键盘,下面为大家介绍几种隐藏键盘的方式. <一> 点击键盘上的 ...
- iOS中键盘的收起
在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法之外,还有另外三种方法: 重载UIViewController中的touchesBegin方 ...
- ios中键盘处理源码
1:先分别设置各个文本框的键盘类型(inputview)-->在特定键盘中textediting中禁用输入. 2:然后递归绑定各个键盘的工具条(inputaccessview).并且个各个控 ...
- H5页面IOS中键盘弹出导致点击错位的问题
IOS在点击输入框弹出键盘 键盘回缩 后 定位没有相应改变 还有 textarea 也会弹出键盘 $("input").blur(function() { console.l ...
- ios 中的构造方法(二)
在之前有简单介绍了构造方法的结构,以及构造方法的作用,那么我们现在来讨论一下: 对象的创建分为两步:+ alloc 分配内存空间和 -init 进行初始化 那么在继承自 NSObject 的类当中,我 ...
- ios中键盘处理适合ipad 和iphone
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UI ...
- ios 中键盘被遮挡解决方案
1.当view是非可以滚动的view时, // 添加对键盘的通知 - -(void)viewDidLoad{ [[NSNotificationCenter defaultCenter] addObse ...
- ios 中生成二维码和相册中识别二维码
iOS 使用CIDetector扫描相册二维码.原生扫描 原生扫描 iOS7之后,AVFoundation让我们终于可以使用原生扫描进行扫码了(二维码与条码皆可)AVFoundation可以让我们从设 ...
- IOS中input键盘事件支持的解决方法
欢迎大家去我的网站详细查看http://genghongshuo.com.cn/ IOS中input键盘事件keyup.keydown.等支持不是很好, 用input监听键盘keyup事件,在安卓手机 ...
随机推荐
- [leetcode]Substring with Concatenation of All Words @ Python
原题地址:https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/ 题意: You are given a ...
- 添加PMD插件扫描潜在的bug
上一节使用checkstyle来规范你的项目主要解决了代码编码规范问题,比如缩进换行等.这次继续代码健康工具类PMD. 什么是PMD PMD真的不像checkstyle这样的东西所见即所得啊,去官网找 ...
- Kaggle 商品销量预测季军方案出炉,应对时间序列问题有何妙招
https://www.leiphone.com/news/201803/fPnpTdrkvUHf7uAj.html 雷锋网 AI 研习社消息,Kaggle 上 Corporación Favorit ...
- 斯坦福深度学习与nlp第四讲词窗口分类和神经网络
http://www.52nlp.cn/%E6%96%AF%E5%9D%A6%E7%A6%8F%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E4%B8%8Enlp%E7%A ...
- R 分组计算描述性统计量
统计学区内各个小区的房价均值 数据格式 id|community_name|house_area|house_structure|house_total|house_avg|agency_name|h ...
- Linux 查看服务器配置
//CPU cat /proc/cpuinfo |grep processor; //内存 free -g; //硬盘 df -h;
- [Algorithm] Delete a node from Binary Search Tree
The solution for the problem can be divided into three cases: case 1: if the delete node is leaf nod ...
- HDU 4059 The Boss on Mars(容斥原理 + 四次方求和)
传送门 The Boss on Mars Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- maven 管理
http://www.cnblogs.com/qq78292959/p/3711501.html
- OSX下安装VMware虚拟机, 加载kali系统
准备 当前环境:OSX 10.11.6 , 准备VMware虚拟机软件和kali系统 为什么要安装kali系统 Kali Linux预装了许多渗透测试软件,包括nmap (端口扫描器).Wiresha ...