首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >lineWidth SwiftUI不正确

lineWidth SwiftUI不正确
EN

Stack Overflow用户
提问于 2020-07-06 19:13:24
回答 1查看 68关注 0票数 1

当我在swift UI中对Rectangle做转角半径时,我得到了下面的输出。

代码语言:javascript
复制
   var body: some View {
        ZStack {
            Rectangle()
                .overlay(Rectangle()
                .stroke(Color.red, lineWidth: 50))
                .foregroundColor(Color.white)
        }
    }

顶部和底部是正确的,但前导和尾随lineWidth是给定值的一半。

如何解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-06 19:29:39

笔划以线条为中心。据我所知,你的期望可以这样解决

使用Xcode11.4/ iOS 13.4进行测试

代码语言:javascript
复制
    ZStack {
        Rectangle()
            .overlay(Rectangle()
                .fill(Color.white).padding(50))
            .foregroundColor(Color.red)
    }.edgesIgnoringSafeArea(.all) // comment if you don't need full screen
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62754846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档