UIButton * button1 = [UIButton buttonWithType:UIButtonTypeSystem];
button1.backgroundColor = [UIColor yellowColor];
button1.frame = CGRectMake(20, 70, 100, 100);
[button1 addTarget:self action:@selector(doclick) forControlEvents:UIControlEventTouchDown];
//[button1 titleForState:normal];
[button1 setTitle:@"first button" forState:UIControlStateNormal];
[self.window addSubview:button1];
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30061551/viewspace-1684718/ ,如需转载,请注明出处,否则将追究法律责任。