zoukankan      html  css  js  c++  java
  • 【代码笔记】iOS-removeFromSuper

    代码:

    RootViewController.m

    复制代码
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        self.title=@"removeFromSuperView";
        
        
        UILabel *tryLabel=[[UILabel alloc]initWithFrame:CGRectMake(50, 150, 200, 50)];
        tryLabel.backgroundColor=[UIColor redColor];
        [self.view addSubview:tryLabel];
        
    }
    //当点击任意处时,把UILabel去掉
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        [self removeFromView];
    }
    -(void)removeFromView
    {
        //点击后删除之前的PickerView
        for (UIView *view in self.view.subviews) {
            if ([view isKindOfClass:[UILabel class]]) {
                [view removeFromSuperview];
            }
            
        }
    
    }
    复制代码
  • 相关阅读:
    io
    文件
    诚实
    没有犯错并不代表自己就是做得好
    脑力锻炼的随缘
    电路运算
    “容错率”
    GPU简介
    名与责任
    失眠和精神的思考
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/6991253.html
Copyright © 2011-2022 走看看