美文网首页
iOS 给view添加虚线边框

iOS 给view添加虚线边框

作者: 夏天爱西瓜汁 | 来源:发表于2017-11-28 11:20 被阅读23次

    2016.7.27

    CAShapeLayer*border = [CAShapeLayerlayer];

    border.strokeColor= [UIColorhexStringToColor:@"#cccccc"].CGColor;

    border.fillColor=nil;

    border.path= [UIBezierPathbezierPathWithRect:self.frontBtn.bounds].CGPath;

    border.frame=self.frontBtn.bounds;

    border.lineWidth=1.f;

    border.lineCap=@"square";

    border.lineDashPattern=@[@2,@2];//虚线的长和间距

    [self.frontBtn.layeraddSublayer:border];

    相关文章

      网友评论

          本文标题:iOS 给view添加虚线边框

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