我想创建一个 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];
任何想法 ?
谢谢