clipsToBounds属性

clipsToBounds属性

意思是:主视图设置属性clipsToBounds=Yes时,添加子视图的时候如果子视图超过主视图边境时子视图超过部分隐藏

直接上代码:



- (void)viewDidLoad {

    [super viewDidLoad];

    UIView *v=[[UIView alloc]init];

    v.backgroundColor=[UIColor redColor];

    v.clipsToBounds=NO;

    v.frame=CGRectMake(30 , 30, 100, 300);

    [self.view addSubview:v];

     

    UIView *v1=[[UIView alloc]init];

    v1.backgroundColor=[UIColor greenColor];

    v1.frame=CGRectMake(0, 0, 300, 200);

    [v addSubview:v1];

}

 运行结果:

clipsToBounds属性