我在自定義 TextField 欄位時遇到問題,我想嘗試使兩者的邊框都等于第一個影像的邊框:
- 邊框顏色
- 邊厚尺寸
- 邊緣倒圓的型別
誰能給我建議?
我想達到的結果:

結果我得到:

HStack(alignment: .center) {
Spacer()
TextField("Git Repository URL", text: $repoUrlStr)
.textFieldStyle(PlainTextFieldStyle())
.lineLimit(1)
.frame(width: 300)
.onAppear {
let url = "https://github.com/name/name"
if isValid(url: url) == true {
print("ok", url)
}
}
Button {
if !repoUrlStr.isEmpty {
self.repoUrlStr = ""
}
} label: {
Image(systemName: "xmark.circle.fill")
.padding(.trailing, 2)
.font(.system(size: 12))
}
.buttonStyle(PlainButtonStyle())
.opacity(repoUrlStr.isEmpty ? 0 : 1)
Spacer()
}
.padding([.top, .bottom], 4)
.border(Color.gray, width: 2)
.cornerRadius(3)
.padding(.bottom, 15)
uj5u.com熱心網友回復:
嘗試在背景中使用圓角矩形(帶有所需的引數,如角半徑、顏色等)而不是邊框??,如
.background(
RoundedRectangle(cornerRadius: 8)
.stroke(your_color_here)
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/452454.html
標籤:迅速 代码 迅捷 uitextfield 文本域
上一篇:如何添加驗證資料搜索
