我正在努力寻找一种方法来简单地为我的UILabel文本添加轮廓/笔触/轮廓.谈论围绕UILabel背景的文字字母的笔划.
我正在使用swift 3,我想直接将我的文本概述到我的子类中:UILabel.
我找到了多个答案,建议这样做:
let strokeTextAttributes = [
NSStrokeColorAttributeName : UIColor.black,
NSForegroundColorAttributeName : UIColor.white,
NSStrokeWidthAttributeName : -4.0,
NSFontAttributeName : UIFont.boldSystemFont(ofSize: 30)
]
self.attributedText = NSMutableAttributedString(string: self.text!, attributes: strokeTextAttributes)
Run Code Online (Sandbox Code Playgroud)
但问题是它不起作用.我的文字仍然相同,没有大纲......
谁能在这帮助我?那将是一件好事:)
非常感谢.干杯伙计们.
我正在尝试找到一种使用MapKit在地图上显示用户方向的方法。MapKit的本机方法总是旋转整个地图。由于用户位置也是MKAnnotationView,因此我决定创建一个特定的类来覆盖它并使用特定的图像(带有箭头)。
class UserLocationAnnotationView: MKAnnotationView {
override init(frame: CGRect) {
super.init(frame: frame)
}
override init(annotation: MKAnnotation!, reuseIdentifier: String!) {
super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
var frame = self.frame
frame.size = CGSizeMake(130, 130)
self.frame = frame
self.backgroundColor = UIColor.clearColor()
self.centerOffset = CGPointMake(-30, -50)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
*/
override func drawRect(rect: CGRect) {
// Drawing code
UIImage(named: "userLocation.png")?.drawInRect(CGRectMake(65, 65, …Run Code Online (Sandbox Code Playgroud)