【问题标题】:Design with dashed line and arc in middle of the UIViewUIView 中间用虚线和圆弧设计
【发布时间】:2017-11-13 10:18:50
【问题描述】:

我正在设计一个具有相当复杂 UI 的屏幕。

UIView 中间是虚线,左右两边是圆弧。

请查看下图以更好地理解。

谁能指导我如何在 iOS 中实现这样的设计?

【问题讨论】:

  • 我会说:它只是一个蒙版,我会使用 UIBezierPath 来绘制蒙版。
  • 你能指导我怎么做吗?
  • stackoverflow.com/questions/43668491/…(知道如何屏蔽)。其余的,寻找 UIBezierPath 应该有一些教程。你不会找到你想要的确切形状,而是如何使用它。

标签: ios iphone swift autolayout


【解决方案1】:

使用此代码创建带有自定义参数的虚线:

let  path = UIBezierPath()

let  point1 = CGPointMake(CGRectGetMinX(self.bounds),CGRectGetMidY(self.bounds))
path.moveToPoint(point1)

let  point2 = CGPointMake(CGRectGetMaxX(self.bounds),CGRectGetMidY(self.bounds))
path.addLineToPoint(point2)

let  dashes: [CGFloat] = [12.0, 24.0]
path.setLineDash(dashes, count: dashes.count, phase: 0.0)

path.lineWidth = 10.0
path.lineCapStyle = .Butt
UIColor.greenColor().set()
path.stroke()

对于框架,只需使用一个矩形和一个圆(你会得到一个圆弧)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多