您的位置:首页 > 产品设计 > UI/UE

隐藏指定的UIView区域

2015-06-20 22:35 417 查看

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;

}





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: