我正在寻找一些关于如何使用Swift2for 在圆形边缘周围绘制简单单线串的最新帮助/提示iOS9.我看到涉及旧ObjC片段的相当陈旧的例子,并且仅限于此OS X.这在自定义UIView子类的drawRect()方法中是否可以在iOS中实现?
我有几十个文本,我想lastTextBaseline放置它们的前导基线 ( ) 位于特定坐标处。position只能设置中心。例如:
import SwiftUI
import PlaygroundSupport
struct Location: Identifiable {
let id = UUID()
let point: CGPoint
let angle: Double
let string: String
}
let locations = [
Location(point: CGPoint(x: 54.48386479999999, y: 296.4645408), angle: -0.6605166885682314, string: "Y"),
Location(point: CGPoint(x: 74.99159120000002, y: 281.6336352), angle: -0.589411952788817, string: "o"),
]
struct ContentView: View {
var body: some View {
ZStack {
ForEach(locations) { run in
Text(verbatim: run.string)
.font(.system(size: 48))
.border(Color.green)
.rotationEffect(.radians(run.angle))
.position(run.point)
Circle() // Added to show …Run Code Online (Sandbox Code Playgroud)