美文网首页
SwiftUI—用Rectangle绘制矩形

SwiftUI—用Rectangle绘制矩形

作者: anny_4243 | 来源:发表于2020-07-14 11:14 被阅读0次

原文链接:https://github.com/fzhlee/SwiftUI-Guide#-%E7%AC%AC31%E8%8A%82shape-rectangle-

使用Rectangle绘制矩形,使用RoundedRectangle绘制圆角矩形。

示例代码:

VStack{
            
    Rectangle()
    Rectangle()
    .fill(Color.orange)
    .frame(width: 200, height: 200)

    ZStack {
       Rectangle().fill(Color.purple)
    .frame(width: 300, height: 200)

       Rectangle().fill(Color.yellow)
    .frame(width: 300, height: 200)
    .scaleEffect(0.8)

       Rectangle()
    .fill(Color.orange)
    .frame(width: 300, height: 200)
    .scaleEffect(0.6)
    }

    RoundedRectangle(cornerRadius: 120) //绘制一个圆角矩形,并设置它的圆角半径为120

    RoundedRectangle(cornerSize: CGSize(width: 100, height: 40)).frame(width: 300, height: 200) //设置圆角的宽度为100,圆角的高度为40

    RoundedRectangle(cornerRadius: 100, style: RoundedCornerStyle.continuous) //圆角样式为continuous连续型,也就是连续曲率的圆角

}

相关文章

网友评论

      本文标题:SwiftUI—用Rectangle绘制矩形

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