私は、ユーザーインターフェイスの2 UILabels、他の上にものを作成示唆しています。それらの位置に制約する。 、下のラベル
bottomLabel.roundCorners(UIRectCorner.BottomLeft, radius: 10)
bottomLabel.roundCorners(UIRectCorner.BottomRight, radius: 10)
最後の一番下の角を丸める次にトップラベル
topLabel.roundCorners(UIRectCorner.TopLeft, radius: 10)
topLabel.roundCorners(UIRectCorner.TopRight, radius: 10)
の上部の角を丸める次に
extension UILabel {
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
var bounds: CGRect = self.bounds
var maskPath: UIBezierPath = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSizeMake(radius, radius))
var maskLayer: CAShapeLayer = CAShapeLayer()
maskLayer.frame = bounds
maskLayer.path = maskPath.CGPath
self.layer.mask = maskLayer
var frameLayer: CAShapeLayer = CAShapeLayer()
frameLayer.frame = bounds
frameLayer.path = maskPath.CGPath
frameLayer.strokeColor = UIColor.redColor().CGColor
frameLayer.fillColor = nil
self.layer.addSublayer(frameLayer)
}
}
境界線を追加します。そして、この拡張機能を追加します。
for label in [topLabel, bottomLabel] {
label.layer.borderColor = UIColor.blueColor.CGColor
label.layer.borderWidth = 1
}
編集可能ですか? – marosoaie
いいえ..ただ読んでほしいだけのテキスト – cana
あなたはwebviewを使用していますか?ネイティブビューを使用してこれを構築したくないですか? – marosoaie