ale*_*ngn 0 objective-c uiview ios
我想创建一个UIButton并将其添加到多个UIView上,但它不能像这样工作:
UIButton *myBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[myBtn setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 44.0f)];
[myBtn setTitle:@"MyButton" forState:UIControlStateNormal];
UIView *myView1 = [[UIView alloc] init];
[myView1 setFrame:CGRectMake(0.0f, 0.0f, 300.0f, 50.0f)];
[myView1 addSubview:myBtn];
UIView *myView2 = [[UIView alloc] init];
[myView2 setFrame:CGRectMake(0.0f, 0.0f, 200.0f, 100.0f)];
[myView2 addSubview:myBtn];
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?
谢谢
| 归档时间: |
|
| 查看次数: |
146 次 |
| 最近记录: |