作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用两个彼此相邻放置的UIButton在iOS上创建一个Split Button。像这样:
如您所见,右按钮的左上角有一小口,这是不可取的。我想中风的那部分完成。
右侧按钮使用UIBezierPath作为子层在按钮周围绘制边框:
let borderWidth = CGFloat(4.0)
let borderLayer = CAShapeLayer()
var borderFrame = button.bounds.insetBy(dx: borderWidth/2.0, dy: borderWidth/2.0)
borderLayer.frame = borderFrame
borderFrame.origin = CGPoint.zero
borderLayer.path = UIBezierPath(roundedRect: borderFrame, byRoundingCorners: [.topRight, .bottomRight], cornerRadii: radius).cgPath
borderLayer.lineWidth = borderWidth
borderLayer.fillColor = UIColor.white.cgColor
borderLayer.strokeColor = UIColor.green.cgColor
button.layer.addSublayer(borderLayer)
borderLayer.path = CGPath(rect: borderFrame, transform: nil)
最佳答案
import UIKit
let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 40, height: 40), byRoundingCorners: [.topRight, .bottomRight], cornerRadii: CGSize(width: 10, height: 10))
print(path)
<UIBezierPath: 0x6180000a5d00; <MoveTo {0, 0}>,
<LineTo {24.713349999999998, 0}>,
<CurveTo {33.300654247944713, 0.65495893024402596} {29.115070423814711, 0} {31.315930559369978, 0}>,
<LineTo {33.685062071690076, 0.74911387847016009}>,
<CurveTo {39.250886121529845, 6.3149379283099272} {36.27176173374253, 1.6905955604436995} {38.30940443955631, 3.7282382662574722}>,
<CurveTo {40, 15.286649847295823} {40, 8.6840694406300223} {40, 10.884929576185289}>,
<LineTo {40, 24.713349999999998}>,
<CurveTo {39.345041069755972, 33.300654247944713} {40, 29.115070423814711} {40, 31.315930559369978}>,
<LineTo {39.250886121529845, 33.685062071690076}>,
<CurveTo {33.685062071690076, 39.250886121529838} {38.30940443955631, 36.27176173374253} {36.27176173374253, 38.309404439556296}>,
<CurveTo {24.713350152704177, 40} {31.315930559369978, 40} {29.115070423814711, 40}>,
<LineTo {0, 40}>,
<LineTo {0, 0}>,
<LineTo {0, 0}>
let path = UIBezierPath(roundedRect: borderFrame, byRoundingCorners: [.topRight, .bottomRight], cornerRadii: radius)
path.close()
borderLayer.path = path.cgPath
关于ios - UIBezierPath行程不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45360804/
我开发了一个 Android 应用程序,允许实时跟踪用户在 map 上制作的类(class)(Google Map Android V2),我接下来要做的是在类(class)结束后我想给例如,用户有机
我一直在bing / google(布尔)搜索中,发现一些命中(主要是在stackoverflow上),并且尝试使用建议的解决方案没有任何运气。 我正在使用Java 8和DBUnit 2.5.1和my
我有一个String[][]。所以它基本上看起来像这样: { { "Dublin", "NYC"}, { "Moscow", "Los-Angeles"}, { "London", "Pa
我是一名优秀的程序员,十分优秀!