美文网首页
UIImageView shadowOpacity操作

UIImageView shadowOpacity操作

作者: 孟小凡 | 来源:发表于2018-01-08 16:09 被阅读0次

UIImageView实现阴影处理

UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 50, 50)];;

    imageView.backgroundColor = [UIColor whiteColor];

    //添加边框

    CALayer * layer = [imageView layer];

    layer.borderColor = [[UIColor yellowColor] CGColor];

    layer.borderWidth = 5.0f;

    //添加四个边阴影

    imageView.layer.shadowColor = [UIColor redColor].CGColor;

    imageView.layer.shadowOffset = CGSizeMake(0, 0);

    imageView.layer.shadowOpacity = 0.5;

    imageView.layer.shadowRadius = 3;

    //添加两个边阴影

    imageView.layer.shadowColor = [UIColor redColor].CGColor;

    imageView.layer.shadowOffset = CGSizeMake(10, 1);

    imageView.layer.shadowOpacity = 0.5;

    imageView.layer.shadowRadius = 2.0;

    [self.view addSubview:imageView];

相关文章

网友评论

      本文标题:UIImageView shadowOpacity操作

      本文链接:https://www.haomeiwen.com/subject/plebnxtx.html