迅速平滑的圆角 [英] smooth rounded corners in swift
问题描述
如何创建带有圆角的UIButton? 标准的苹果圆角比标准的圆角好得多. 如果我在草图中设计一个按钮,则可以切换平滑角",从而将形状的角从Apple圆角(平滑)切换到标准圆角.
How can I create a UIButton with rounded corners that are smooth? The standard apple rounded corners are much nicer than the standard rounded corners. If I design a button in sketch, I can toggle "smooth corners" which toggles the corners of a shape from Apple rounded corners (smooth) to standard rounded corners.
这里是一个比较:
如何快速切换?
showContentButton.layer.cornerRadius = 20
是圆角,但是,我真的不知道这个圆角是平滑角"还是标准圆角".而且我不知道该如何切换.有什么想法吗?
showContentButton.layer.cornerRadius = 20
rounds the corners, however, I don't really know if this rounded corners are "smooth corners" or "standard rounded corners". And I don't know how to toggle this. Any ideas?
推荐答案
从 iOS 13.0 开始,除了设置cornerRadius之外,您还可以使用此属性:
Starting iOS 13.0, you can just use this property in addition to setting the cornerRadius:
sampleButton.layer.cornerCurve = .continuous
这也很容易制作动画,以前使用UIBezierPath导致出现问题.
This is also easily animatable, which previously resulted in problems using a UIBezierPath.
在 https://developer.apple.com/documentation/quartzcore中了解更多/calayer/3152596-cornercurve
这篇关于迅速平滑的圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!