源码地址:https://github.com/fzhlee/SwiftUI-Guide
给图片进行图像颜色的设置:设置模糊效果、设置图片的亮度、反转图片的颜色、对比度等效果
示例代码:
ScrollView{
VStack{
Image("girlPicture")
Image("girlPicture")
.blur(radius: CGFloat(2))
Image("girlPicture")
.blur(radius: CGFloat(2), opaque: true)
Image("girlPicture")
.brightness(0.2)
Image("girlPicture")
.colorInvert()
Image("girlPicture")
.colorMultiply(Color.yellow)
Image("girlPicture")
.contrast(1.5)
}
VStack{
Image("girlPicture")
.hueRotation(Angle.degrees(180))
Image("girlPicture")
.saturation(10)
Image("girlPicture")
.grayscale(5.5)
Image("girlPicture")
.luminanceToAlpha()
}
}
查看运行结果




本文详细介绍使用SwiftUI为图片应用各种图像效果的方法,包括模糊、亮度调整、颜色反转、对比度增强、色调旋转、饱和度调整、灰度转换及将亮度转换为透明度等。通过示例代码展示如何轻松修改图片视觉效果。
427

被折叠的 条评论
为什么被折叠?



