0
我一直在努力做到這一點在這樣的遊樂場:如何使一個虛線或虛線斯威夫特4
import UIKit
import XCPlayground
let path = UIBezierPath()
path.move(to: CGPoint(x:10,y:10))
path.addLine(to: CGPoint(x:290,y:10))
path.lineWidth = 2
let dashPattern : [CGFloat] = [0, 16]
path.setLineDash(dashPattern, count: 2, phase: 0)
path.lineCapStyle = CGLineCap.round
path.lineCapStyle = .butt
UIGraphicsBeginImageContextWithOptions(CGSize(width:300, height:20), false, 2)
path.stroke()
XCPlaygroundPage.currentPage.captureValue(value: UIGraphicsGetImageFromCurrentImageContext(), withIdentifier: "image")
UIGraphicsEndImageContext()
但結果是:
謝謝!這就是訣竅:) – Menno
@Ola Begemann我們如何爲iOS 9做到這一點? –