美文网首页
iOS给控件或view添加阴影图层

iOS给控件或view添加阴影图层

作者: AnderQZ | 来源:发表于2017-03-24 21:02 被阅读823次
    CGPoint position= CGPointMake(_blueView.center.x, _blueView.center.y);//阴影中心点
    CGFloat borderWidth = 2;
    //阴影图层
    CALayer *layerShadow=[[CALayer alloc]init];
    layerShadow.bounds = _blueView.bounds;
    layerShadow.position = position;
    layerShadow.shadowColor = [UIColor grayColor].CGColor;
    layerShadow.shadowOffset = CGSizeMake(2, 1);
    layerShadow.shadowOpacity = 1;
    layerShadow.borderColor = [UIColor whiteColor].CGColor;
    layerShadow.borderWidth = borderWidth;
    [self.view.layer addSublayer:layerShadow];

    相关文章

      网友评论

          本文标题:iOS给控件或view添加阴影图层

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