iOS代码生成Button

2020-06-09  本文已影响0人  Zhen斌iOS

代码如下:

CGRect frame = CGRectMake(0, 400, 72.0, 37.0);
UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.frame = frame;
[buttonsetTitle:@"按钮"forState: UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
button.tag = 2000;
[buttonaddTarget: self action: @selector(buttonClicked:) forControlEvents: UIControlEventTouchUpInside];
[self.view addSubview: button];

希望对你有帮助!

上一篇下一篇

猜你喜欢

热点阅读