美文网首页
使用SwiftUI设置不同位置的圆角

使用SwiftUI设置不同位置的圆角

作者: zhlv | 来源:发表于2024-09-10 16:53 被阅读0次

在项目中很多时候会遇到圆角,当然圆角很多种方式
设置圆角

 ZStack {
                Color.blue
                    .frame(width: 200, height: 100)
                Text("圆角视图")
                    .font(.title)
                    .foregroundColor(.white)
            }
            .clipShape(RoundedRectangle(cornerRadius: 15, style: .continuous))
////////////////
 GeometryReader {
                let size = $0.size
                MyAsyncImage(url: "https://img0.baidu.com/it/u=3985000706,2181490320&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1200")
                    .aspectRatio(contentMode: .fill)
                    .frame(width: size.width, height: size.width)
                    .cornerRadius(size.width/2)
                //
            }
WX20240911-164731@2x.png WX20240911-164703@2x.png

四个角不同大小圆角的设置

 GeometryReader {
                let size = $0.size
                MyAsyncImage(url: "https://img0.baidu.com/it/u=3985000706,2181490320&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1200")
                    .aspectRatio(contentMode: .fill)
                    .frame(width: size.width, height: size.height)
                    .clipShape(.rect(topLeadingRadius: 10, bottomLeadingRadius: 0, bottomTrailingRadius: 30, topTrailingRadius: 80))
                //
            }
WX20240911-164436@2x.png

相关文章

网友评论

      本文标题:使用SwiftUI设置不同位置的圆角

      本文链接:https://www.haomeiwen.com/subject/jbduljtx.html