I am trying to add a stroke to a UILabel text in Swift. This is the text I have used:
var congratsLabel = UILabel(frame: CGRectMake(10, popUpView.frame.size.height * 0.540, popUpView.frame.size.width, 70))
congratsLabel.font = UIFont(name: Font.Daydreamer, size: 70)
congratsLabel.text = "Snap!"
congratsLabel.numberOfLines = 0
congratsLabel.textColor = UIColor.whiteColor()
congratsLabel.textAlignment = NSTextAlignment.Center
popUpView.addSubview(congratsLabel)
I have also tried using the NSMutableAttributedString
althoough it is coming out a bit ropey and not how I want, the code I used for that also was:
var String = "Snap!"
var strokeString = NSMutableAttributedString(string: String, attributes: [NSFontAttributeName:UIFont(name: Font.Daydreamer, size: 70.0)!])
strokeString.addAttribute(NSForegroundColorAttributeName, value: UIColor.whiteColor(), range: NSRange(location:0,length:5))
strokeString.addAttribute(NSStrokeColorAttributeName, value: UIColor.blackColor(), range: NSRange(location: 0, length: 5))
strokeString.addAttribute(NSStrokeWidthAttributeName, value: 1, range: NSRange(location: 0, length: 5))
This is the look I am trying to recreate.
But it is coming out like this (The backgrounds are different) but as you can see the stroke is taking over the entire word: