我的/Library/Developer/CoreSimulator
文件夹有 27 GB,其中/Library/Developer/CoreSimulator/Images
占用了 15 GB,/Library/Developer/CoreSimulator/Profiles
占用了 12 GB。我可以清除这些文件夹中的任何内容而不破坏任何内容吗?
请记住,这是一个不同的文件夹,~/Library/Developer/CoreSimulator
大小仅有 3 GB。
我的/Library/Developer/CoreSimulator
文件夹有 27 GB,其中/Library/Developer/CoreSimulator/Images
占用了 15 GB,/Library/Developer/CoreSimulator/Profiles
占用了 12 GB。我可以清除这些文件夹中的任何内容而不破坏任何内容吗?
请记住,这是一个不同的文件夹,~/Library/Developer/CoreSimulator
大小仅有 3 GB。
我正在制作一个 TextField,在输入时,它有一个浮动标签,该标签会切入 TextField 的边框。对于不同的占位符,修剪功能无法按预期工作,例如,如果修剪功能对占位符“名称”正常工作,则对占位符“输入名称”不起作用。此外,第一次在字段中输入时,FocusState 会更改为 false。为什么会发生这种情况?有人可以帮忙修复这些问题吗?
视图代码:
struct RoundedTextField: View {
@Binding var text: String
let placeholder: String
init(_ placeholder: String, text: Binding<String>) {
self.placeholder = placeholder
self._text = text
}
@State private var width: CGFloat = .zero
@State private var labelWidth: CGFloat = .zero
@FocusState private var isFieldFocused
var body: some View {
ZStack(alignment: .leading) {
Text(placeholder)
.foregroundStyle(text.isEmpty ? Color(.placeholderText) : .caribe)
.padding(.horizontal, 25)
.offset(y: text.isEmpty ? 0 : -37)
.scaleEffect(text.isEmpty ? 1 : 0.8, anchor: .leading)
.overlay {
GeometryReader { proxy in
Color.clear
.onChange(of: text) { _, _ in
labelWidth = proxy.size.width
}
}
}
TextField("", text: $text)
.textFieldStyle(RoundedTextFieldStyle(isFieldFocused: isFieldFocused, textIsEmpty: text.isEmpty, width: width, labelWidth: labelWidth))
.focused($isFieldFocused)
.overlay {
GeometryReader { proxy in
Color.clear
.onChange(of: text) { _, _ in
width = proxy.size.width * (text.isEmpty ? 1 : 0.8)
}
}
}
}
.animation(.default, value: text)
.padding()
}
}
struct RoundedTextFieldStyle: TextFieldStyle {
var isFieldFocused: Bool
var textIsEmpty: Bool
var width: CGFloat
var labelWidth: CGFloat
func _body(configuration: TextField<Self._Label>) -> some View {
configuration
.padding(.vertical)
.padding(.horizontal, 25)
.frame(height: 60)
.if(textIsEmpty) { view in
view.background {
RoundedRectangle(cornerRadius: 10)
.stroke(isFieldFocused ? .caribe : .gray, lineWidth: isFieldFocused ? 2 : 1)
}
}
.if(!textIsEmpty) { view in
view.background {
ZStack {
RoundedRectangle(cornerRadius: 10)
.trim(from: 0, to: 0.55)
.stroke(isFieldFocused ? .caribe : .gray, lineWidth: isFieldFocused ? 2 : 1)
RoundedRectangle(cornerRadius: 10)
.trim(from: 0.565 + 0.2 * (labelWidth / width), to: 1)
.stroke(isFieldFocused ? .caribe : .gray, lineWidth: isFieldFocused ? 2 : 1)
}
}
}
}
}
条件修饰符:
extension View {
@ViewBuilder
func `if`<Content: View>(_ condition: Bool, transform: (Self)-> Content) -> some View {
if condition {
transform(self)
} else {
self
}
}
}