zoukankan      html  css  js  c++  java
  • objectivec 把所有类型为UIButton的子控件放在父视图中央 动态创建按钮

        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(9020020060);  
        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];  

    }   

  • 相关阅读:
    高级映射之事务
    配置tomcat-users.xml文件
    动态SQL之标签
    性能测试
    Service
    添加 aar 或 jar 包依赖 的方式
    安卓设备 以太网代理 问题排查
    剑指offer:面试题15、链表中倒数第 K 个结点
    剑指offer:面试题14、调整数组顺序使奇数位于偶数前面
    剑指offer:面试题13、在O(1)时间删除链表结点
  • 原文地址:https://www.cnblogs.com/zyip/p/2695950.html
Copyright © 2011-2022 走看看