@property (weak, nonatomic) IBOutlet UIView *customView;
@property (weak, nonatomic) IBOutlet UIImageView *iconView;
@end
复制代码
@implementation YYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
//设置图片layer的边框宽度和颜色
self.iconView.layer.borderColor=[UIColor brownColor].CGColor;
self.iconView.layer.borderWidth=5;
//设置layer的圆角
self.iconView.layer.cornerRadius=20;
//设置超过子图层的部分裁减掉
self.iconView.layer.masksToBounds=YES;
}
设置bounds属性,在设置时需要去除掉storyboard中的自动布局属性。
设置图片的形变属性(transform)
复制代码@implementation YYViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//通过uiview设置(2D效果)
// self.iconView.transform=CGAffineTransformMakeTranslation(0, -100);
//通过layer来设置(3D效果,x,y,z三个方向)
self.iconView.layer.transform=CATransform3DMakeTranslation(100, 20, 0);
}
通过uiview设置(2D效果)












