标签归档:按钮

object c 源代码动态增加按钮,并给按钮一个点击事件

object c 源代码动态增加按钮,并给按钮一个点击事件 – (void)viewDidLoad { [super viewDidLoad]; CGRect frame = CGRectMake(90, 200, 200, 60); UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = frame; btn.backgroundColor = [UIColor clearColor]; [btn setTitle:@"动态添加一个按钮!" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(Edit:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; // Do any additional … 继续阅读

发表在 Xcode | 标签为 , , , | 留下评论