CAlayer层树是cocoa视图继承树的同等物,它具备UIView的很多共同点,但是Core Animation没有提供一个 方法展示在窗口。他们必须宿主到UIView中,并且UIView给他们提供响应的方法。所以UIReponder就是UIView的又一个大的特性。
imageview =[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
imageview.layer.masksToBounds =YES;
imageview.layer.cornerRadius =5; // 圆角
imageview.layer.borderColor =[UIColor orangeColor].CGColor; //边框
imageview.layer.borderWidth =1.0;
imageview.layer.shadowOffset =CGSizeMake(1, 1); //阴影
imageview.layer.shadowRadius =5.0;
imageview.layer.shadowColor =[UIColor redColor].CGColor;
imageview.layer.shadowOpacity =0.8;
[self.view addSubview:imageview];