How do I create a basic UIButton programmatically?

后端 未结 30 1327
清歌不尽
清歌不尽 2020-11-22 14:41

How can I create a basic UIButton programmatically? For example in my view controller, when executing the viewDidLoad method, three UIButton<

30条回答
  •  礼貌的吻别
    2020-11-22 15:08

    UIButton *buttonName = [UIButton
    buttonWithType:UIButtonTypeRoundedRect];
    [buttonName addTarget:self 
        action:@selector(aMethod:)forControlEvents:UIControlEventTouchDown];
    [buttonName setTitle:@"Show View" forState:UIControlStateNormal];
    .frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [view
    addSubview:buttonName];
    

提交回复
热议问题