【问题标题】:Add border all-around and only bottom right cornet radius in swift 2.0在 swift 2.0 中添加边框和仅右下角的短号半径
【发布时间】:2015-12-03 15:17:52
【问题描述】:

我想为我的 UIView 添加边框,只有左下角半径。我正在使用以下代码来实现所需的结果,但正在工作我是 swift 的新手

var layer = CAShapeLayer()
    layer.bounds = self.myView.bounds

    layer.borderColor = UIColor.whiteColor().CGColor
    layer.borderWidth = 2

    callayer.path = UIBezierPath(roundedRect: self.imgView.bounds, byRoundingCorners: [.BottomRight], cornerRadii: CGSize(width: 20, height: 20)).CGPath
    self.myView.layer.mask = layer

结果

我是 swift 新手。我的 UIView 如何才能同时拥有一个圆角半径和边框?

【问题讨论】:

    标签: swift2 ios9 xcode7


    【解决方案1】:
        self.myView.layer.borderWidth = 2.0
       self.myView.layer.borderColor = UIColor.whiteColor().CGColor
       self.myView.layer.cornerRadius =  /*floatvalue*/
    

    或者你想要一个圆形视图

     self.myView.layer.cornerRadius =  self.myView.frame.size.width/2 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-25
      • 2020-05-07
      • 1970-01-01
      • 2019-12-23
      相关资源
      最近更新 更多