利用UIKit,我们可以采用以下方式使控件(例如按钮)拥有完美的圆角(在每侧呈现为圆形):
exampleButton.cornerRadius = exampleButton.frame.size.height/2
如何使用SwiftUI视图实现相同的结果?
由于视图更多地是即时定义的,所以我不确定除非手动设置它(这不是这里想要的),否则如何引用该框架大小。
Button(action: {
// ...
}) {
Text("I'm a Button")
}
.cornerRadius(???)