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];  

    }   

  • 相关阅读:
    go语言入门(3)运算符及流程控制
    go语言入门(2)数据类型
    go语言入门(1)
    ubuntu上软件下载慢,github下载慢
    密码基础知识(2)以RSA为例说明加密、解密、签名、验签
    让你减少焦虑的一首英文小诗
    使用脚本启动fabric时出错
    Hyperledger Fabric(5)ChainCode的编写步骤
    Hyperledger Fabric(4)链码ChainCode
    设计题专题总结
  • 原文地址:https://www.cnblogs.com/zyip/p/2695950.html
Copyright © 2011-2022 走看看