隐藏指定的UIView区域

1.说明

使用UIView的属性hidden隐藏指定的区域,属性hidden值为YES时隐藏UIView,属性hidden值为NO时显示UIView

2.实例

起:点击按钮

终:实现文本隐藏和文本显示切换


.h


#import <UIKit/UIKit.h>

@interface UIKitPrjFrame : UIViewController {

    @private
    UILabel * _label;
}

@end


.m


#import "UIKitPrjFrame.h"

@interface UIKitPrjFrame ()

@end

@implementation UIKitPrjFrame

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor blackColor];
    _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
    _label.textAlignment = NSTextAlignmentCenter;
    _label.backgroundColor = [UIColor blackColor];
    _label.textColor = [UIColor whiteColor];
    _label.text = @"Im' here";
    
    [self.view addSubview:_label];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(0, 0, 100, 40);
    CGPoint newPoint = self.view.center;
    newPoint.y = self.view.frame.size.height - 70;
    button.center = newPoint;
    [button setTitle:@"点击" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonDidPush) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:button];
    
}

- (void)buttonDidPush {
    
    _label.hidden = !_label.hidden;
    
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值