iOS 给view添加虚线边框
2017-11-28 本文已影响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];