首先 添加图片到项目
UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1"]];
imageView.center = self.view.center;
[self.view addSubview:imageView];
//设置阴影
imageView.layer.shadowColor = [[UIColor yellowColor]CGColor];
//阴影偏移
imageView.layer.shadowOffset= CGSizeMake(10, 10);
//阴影透明度
imageView.layer.shadowOpacity = 0.5;
//阴影圆角大小
imageView.layer.cornerRadius = 8;
imageView.layer.masksToBounds = YES;//必须设置这个属性才能圆角
//设置边框
imageView.layer.borderWidth = 8;
imageView.layer.borderColor = [[UIColor redColor]CGColor];
//设置旋转
// imageView.layer.transform = CATransform3DMakeRotation(M_PI_4, 1, 1, 0);
imageView.layer.transform = CATransform3DMakeScale(0.5, 1, 1);
这里要注意:如果要设置图层圆角,必须要设置
imageView.layer.masksToBounds = YES;//必须设置这个属性才能圆角
时间: 2024-11-02 23:26:59