标签:
//
// ViewController.m
// SuperViewSonView
//
// Created by hehe on 15/9/16.
// Copyright (c) 2015年 wang.hehe. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//创建一个父类视图
UIView *mySuperView = [[UIView alloc] init];
mySuperView.frame = CGRectMake(80, 100, 150, 100);
mySuperView.backgroundColor = [UIColor grayColor];
[self.view addSubview:mySuperView];
//创建一个子视图
UIView *mySubView = [[UIView alloc] init];
mySubView.frame = CGRectMake(0, 0, 80, 60);
mySubView.backgroundColor = [UIColor redColor];
[mySuperView addSubview:mySubView];
//视图的隐藏属性
mySuperView.hidden = NO;
//设置透明度
mySuperView.alpha = 0.8;
//设置子视图的透明度= 0.5*0.8=0.4
mySubView.alpha = 0.5;
//改变自视图坐标
mySubView.frame = CGRectMake(20, 20, 180, 60);
//裁减超出父视图边界部分
mySuperView.clipsToBounds = YES;
//改变父视图坐标
mySuperView.frame = CGRectMake(100, 250, 150, 100);
//mySuperView.transform = CGAffineTransformMakeRotation(2);
}
@end
标签:
原文地址:http://www.cnblogs.com/wanghengheng/p/4814946.html