Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. func applyShadow(shadowColor: UIColor, shadowWidth: CGFloat,
  2. shadowHeigt: CGFloat, shadowRadius: CGFloat,
  3. subString: String) {
  4. if let range = self.string.range(of: subString) {
  5. self.applyShadow(shadowColor: shadowColor, shadowWidth: shadowWidth,
  6. shadowHeigt: shadowHeigt, shadowRadius: shadowRadius,
  7. onRange: NSRange(range, in: self.string))
  8. }
  9. }
  10. func applyShadow(shadowColor: UIColor, shadowWidth: CGFloat,
  11. shadowHeigt: CGFloat, shadowRadius: CGFloat,
  12. onRange: NSRange) {
  13. let shadow = NSShadow()
  14. shadow.shadowOffset = CGSize(width: shadowWidth, height: shadowHeigt)
  15. shadow.shadowColor = shadowColor
  16. shadow.shadowBlurRadius = shadowRadius
  17. self.addAttributes([NSAttributedString.Key.shadow : shadow], range: onRange)
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement