Use init(ui
instead.
init(_:)
Deprecated 非推奨
Availability 有効性
- iOS 13.0–15.4 Deprecated
- iPadOS 13.0–15.4 Deprecated
- Mac Catalyst 13.0–15.4 Deprecated
- tvOS 13.0–15.4 Deprecated
- watchOS 6.0–8.5 Deprecated
Technology
- Swift
UI
Declaration 宣言
init(_ color: UIColor
)
Parameters パラメータ
color
A
UIColor
instance from which to create a color.
Discussion 議論
Use this method to create a SwiftUI color from a UIColor
instance. The new color preserves the adaptability of the original. For example, you can create a rectangle using link
to see how the shade adjusts to match the user’s system settings:
struct Box: View {
var body: some View {
Color(UIColor.link)
.frame(width: 200, height: 100)
}
}
The Box
view defined above automatically changes its appearance when the user turns on Dark Mode. With the light and dark appearances placed side by side, you can see the subtle difference in shades:
Note 注意
Use this initializer only if you need to convert an existing UIColor
to a SwiftUI color. Otherwise, create a SwiftUI Color
using an initializer like init(_:
, or use a system color like blue
.