UIKit,UIView
2016-06-28 00:00
183 查看
摘要: 手写代码(UILabel,UITextField,UIButton)
UIKit,手写代码(UILabel,UITextField,UIButton)
UIKit框架
AppDelegate,父类-UIResponder
ViewController,父类-UIViewController
在UI工程中获取文本的方式
NSString str=_*****.text
[_change setTitle : @“change” forState : UIControlStateNormal];
(1)label
//实例化标签,
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(填写坐标和宽高)];
label.text=@“标签";
//添加标签,
[self.view addSubview:label];
(2)textField
//使文本框内容虚化,
field.placeholder=@“hahaha”;
//添加文本框,
field.borderStyle=UITextBorderStyleRoundedRect;
(3)button
//实例化按钮,
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(300, 450, 70, 50)];
//给按钮设置标题,
[button setTitle:@"按钮" forState:UIControlStateNormal];
//设置按钮背景颜色,
button.backgroundColor=[UIColor blackColor];
//给按钮添加点击事件,
[button addTarget:self action:@selector(hit:)forControlEvents:UIControlEventTouchUpInside];
//给按钮设置圆角,
button.layer.cornerRadius=5;
//添加按钮,
[self.view addSubview:button];
//实现方法,
-(void)hit:(UIButton *)sender
UIKit,手写代码(UILabel,UITextField,UIButton)
UIKit框架
AppDelegate,父类-UIResponder
ViewController,父类-UIViewController
在UI工程中获取文本的方式
NSString str=_*****.text
[_change setTitle : @“change” forState : UIControlStateNormal];
(1)label
//实例化标签,
UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(填写坐标和宽高)];
label.text=@“标签";
//添加标签,
[self.view addSubview:label];
(2)textField
//使文本框内容虚化,
field.placeholder=@“hahaha”;
//添加文本框,
field.borderStyle=UITextBorderStyleRoundedRect;
(3)button
//实例化按钮,
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(300, 450, 70, 50)];
//给按钮设置标题,
[button setTitle:@"按钮" forState:UIControlStateNormal];
//设置按钮背景颜色,
button.backgroundColor=[UIColor blackColor];
//给按钮添加点击事件,
[button addTarget:self action:@selector(hit:)forControlEvents:UIControlEventTouchUpInside];
//给按钮设置圆角,
button.layer.cornerRadius=5;
//添加按钮,
[self.view addSubview:button];
//实现方法,
-(void)hit:(UIButton *)sender
相关文章推荐
- 使用UITextField限制输入金额是正确小数
- iOS App中UILabel的自定义及在Auto Layout中的使用
- iOS开发之自定义UITextField的方法
- iOS App开发中UITextField组件的常用属性小结
- iOS应用开发中使UITextField实现placeholder属性的方法
- 详解iOS中UIButton的三大UIEdgeInsets属性用法
- 解决iOS7上UITextField限制字数输入导致崩溃问题的方法
- IOS UI学习教程之设置UITextField各种属性
- iOS - UIButton(UIEdgeInsets)/设置button上的文字和图片上下垂直居中对齐
- Swift社交应用文本输入优化汇总
- Swift之贪婪的UIButton
- UIButton拖动响应事件,距离问题
- IOS 7.1 兼容性bug 问题,UIButton,UILabel ...
- UIKit框架(18)UIButton和UITextField
- UITextField常用delegate
- UILabel的学习
- UILabel显示HTML
- UIButton小结
- UILabel
- UILabel 的NSTextAlignment扩展