简体   繁体   English

UIView cornerRadius-什么?

[英]UIView cornerRadius - of what?

I am familiar with the cornerRadius property of UIView layers, exposed with the QuartzCore framework. 我熟悉QuartzCore框架公开的UIView图层的cornerRadius属性。 The general rule of thumb, of course, is larger values create more rounded edges, and smaller values create less rounded edges. 当然,一般的经验法则是,较大的值将创建更多的圆角,而较小的值将创建较少的圆角。 I'm curious though, the property is called cornerRadius , and I often find myself asking, radius of what? 不过我很好奇,该属性称为cornerRadius ,我经常问自己,半径是多少? What and where is this circle whose radius I'm changing? 我要更改其半径的这个圆在哪里?

Imagine a circle at each corner of the rectangle framing the view. 想象一下在框住视图的矩形的每个角上有一个圆。 The rounded edge of the corner follows the arc of the circle. 角的圆角沿圆弧延伸。 cornerRadius is the radius of that circle. cornerRadius是该圆的半径。

Take the 4 corners of a rectangle. 取一个矩形的4个角。

Starting at the corner points, you pass it a length to which the rounded corner should extend to. 从拐角点开始,传递一个圆角应延伸到的长度。

This is the radius of the corner, or cornerRadius. 这是角的半径,即cornerRadius。

That's how I interpret it. 这就是我的解释方式。 Don't know if that's correct :P 不知道那是正确的:P

This is more of a math question, but the above answer is mostly correct, except that the lines aren't circular. 这更像是一个数学问题,但是上面的答案基本上是正确的,除了直线不是圆形的。 A radius is: 半径为:

A radial line from the focus to any point of a curve. 从焦点到曲线任意点的径向线。

(Source: Oxford ) (来源: 牛津

As an example, note the non-circular curvature of some non-circular gears , which still have radii. 例如,请注意某些非圆齿轮的非圆曲率,该非圆齿轮仍具有半径。

So, it's similar to what's described in the other answers, but the corner curve is not circular. 因此,它与其他答案中描述的相似,但是拐角曲线不是圆形的。 If you're curious about the equation of the curve, just do the radius equation backwards. 如果您对曲线的方程式感到好奇,只需向后做半径方程式即可 :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM