给View添加阴影 和边框

给View添加阴影 和边框

转自:http://ios-iphone.diandian.com/post/2011-09-15/5067179

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;

posted on 2013-01-07 11:16  kiao295338444  阅读(273)  评论(0编辑  收藏  举报

导航