开发者社区 问答 正文

给UIView添加虚线边框

怎么样给UIView添加一个虚线边框?

比如像这样:
screenshot

展开
收起
爵霸 2016-03-24 11:01:04 2782 分享 版权
2 条回答
写回答
取消 提交回答
  • 可以用贝塞尔曲线自己画线,然后添加到layer中。

    2019-07-17 19:12:18
    赞同 展开评论
  • [yourView.layer setBorderWidth:5.0];
    [yourView.layer setBorderColor:[[UIColor colorWithPatternImage:[UIImage imageNamed:@"DotedImage.png"]] CGColor]];///just add image name and create image with dashed or doted drawing and add here

    这里只需要添加QuartzCore/QuartzCore.h框架,像下面一样导入.m文件:
    `
    import
    `

    2019-07-17 19:12:17
    赞同 展开评论
问答地址: