在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
for(UIView *view in [self.backgroundView subviews])
{ //[view removefromsuperview]; if([[[view superclass] description] isEqualToString:@"UIButton"]) { UIButton * btn=(UIButton*) view; btn.titleLabel.text=@"dynamic title"; btn.center=btn.superview.center; } }
- (IBAction)addButton:(id)sender {
CGRect frame = CGRectMake(90, 200, 200, 60); UIButton *someAddButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; someAddButton.backgroundColor = [UIColor clearColor]; [someAddButton setTitle:@"动态添加一个按钮!" forState:UIControlStateNormal]; someAddButton.frame = frame; [someAddButton addTarget:self action:@selector(someButtonClicked) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:someAddButton]; }
-(void) someButtonClicked{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您点击了动态按钮!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; } |
请发表评论