按钮

来源:互联网 发布:mac mini 装win10 编辑:程序博客网 时间:2024/04/28 16:42

  按钮UIButton的基本用法:

 

 

- (void)viewDidLoad {
[super viewDidLoad];
//绘制view
backgroundview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
[backgroundview setBackgroundColor:[UIColor darkGrayColor]];
[backgroundview setOpaque:NO];
//[backgroundview setAlpha:0];
[self.view addSubview:backgroundview];
//绘制按钮
//armbutton = [[UIButton alloc]init];
lanbutton = [UIButton buttonWithType: 111];
[lanbutton setFrame:CGRectMake(10, 10, 100, 25)];
[lanbutton setTintColor:[UIColor redColor]];
 [lanbutton setTitle:@"绘制按钮" forState:UIControlStateNormal];
[lanbutton addTarget:self
  action:@selector(点击响应函数) 
forControlEvents:UIControlEventTouchUpInside];

[backgroundview addSubview:lanbutton];
}

原创粉丝点击