1.    给图片添加阴影效果:

- (void)viewDidLoad {

    [super viewDidLoad];

    UIImage *img = [UIImage imageNamed:@"pic"];

    UIImageView *imgView = [[UIImageView alloc] initWithImage:img];

    imgView.frame = CGRectMake(60, 60, 206, 230);

   //设置图像视图层的阴影颜色

    imgView.layer.shadowColor = [[UIColor blackColor] CGColor];

   //设置图像视图层的阴影横向和纵向的偏移值

    imgView.layer.shadowOffset = CGSizeMake(5.0f, 5.0f);

   //设置视图的阴影透明度

    imgView.layer.shadowOpacity = 0.75;

   //设置阴影半径大小

    imgView.layer.shadowRadius = 20.0f;

    [self.view addSubview:imgView];

}

 

运行效果:

UI10-UIView视图添加阴影效果

相关文章: