尝试在swiftui中为边界设置圆角半径

时间:2020-07-18 15:15:35

标签: ios xcode swiftui

我正在尝试在RoundedRectangle周围创建一个边框,该边框的cornerRadius为25。这是我的代码。

             RoundedRectangle(cornerRadius: 25)
                .fill(Color.white)
                .frame(width: 290, height: 315)
                .border(Color("Dark Text"), width: 3)
                .cornerRadius(25)

根据此代码,矩形的CornerRadius为25,但边框与框架匹配。我如何使边界的角半径为25?

1 个答案:

答案 0 :(得分:1)

这应该做:

>>> data_set
({'deviceTimestamp': 166230, 'x': 3.5538, 'y': -9.7006, 'z': 3.3077}, {'deviceTimestamp': 166250, 'x': -1.4629, 'y': -7.0692, 'z': 2.2308}, {'deviceTimestamp': 166260, 'x': -6.7571, 'y': -5.0299, 'z': -0.076923}, {'deviceTimestamp': 166280, 'x': -5.0319, 'y': -6.5896, 'z': -0.076923}, {'deviceTimestamp': 166300, 'x': -0.21122, 'y': -8.9002, 'z': 2.5}, {'deviceTimestamp': 166320, 'x': 6.3477, 'y': -9.3142, 'z': 4.5385}, {'deviceTimestamp': 166340, 'x': 10.904, 'y': -9.9498, 'z': 5.6538}, {'deviceTimestamp': 166360, 'x': 9.5501, 'y': -8.5014, 'z': 5.6923}, {'deviceTimestamp': 166380, 'x': 7.7312, 'y': -8.5973, 'z': 5.6154}, {'deviceTimestamp': 166400, 'x': 8.9783, 'y': -10.132, 'z': 4.7692}, {'deviceTimestamp': 166420, 'x': 9.8307, 'y': -11.159, 'z': 5.0385}, {'deviceTimestamp': 166440, 'x': 7.7934, 'y': -10.556, 'z': 5.8077}, {'deviceTimestamp': 166460, 'x': 5.8261, 'y': -10.259, 'z': 2.8462}, {'deviceTimestamp': 166480, 'x': 4.4837, 'y': -10.092, 'z': 1.6538}, {'deviceTimestamp': 166500, 'x': 5.5556, 'y': -11.08, 'z': 1.8462}, {'deviceTimestamp': 166520, 'x': 8.4009, 'y': -12.06, 'z': 1.0})

from statistics import stdev 

std_dev={}
for k in 'xyz':
    std_dev[k]=stdev([x for d in data_set for x in  [v for kt,v in d.items() if kt==k]])

>>> std_dev
{'x': 5.3742701745097445, 'y': 1.834613985511212, 'z': 2.0740453969047343}

如果要使用多个修饰符,有时将不允许您使用笔触。例如。与RoundedRectangle(cornerRadius: 25) .stroke(Color.black, lineWidth: 5) // used for border .frame(width: 290, height: 315) 。在这种情况下,请使用fill

overlay