view加阴影和边框

UIImageView *imgvPhoto  = [UIImageView alloc] init];

//添加边框
   CALayer *layer = [_imgvPhoto layer];
    layer.borderColor = [[UIColor whiteColor] CGColor];
    layer.borderWidth = 5.0f;
//添加四个边阴影
    _imgvPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
    _imgvPhoto.layer.shadowOffset = CGSizeMake(0, 0);
    _imgvPhoto.layer.shadowOpacity = 0.5;
    _imgvPhoto.layer.shadowRadius = 10.0;
//添加两个边阴影
    _imgvPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
    _imgvPhoto.layer.shadowOffset = CGSizeMake(4, 4);
    _imgvPhoto.layer.shadowOpacity = 0.5;
    _imgvPhoto.layer.shadowRadius = 2.0;

原文地址:https://www.cnblogs.com/sanjianghuiliu/p/4025808.html