您的位置:首页 > 产品设计 > UI/UE

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息