iOS - Draw gradient - Swift
问题 I'm trying to draw a gradient to UILabel, but it draws only the colors I can't see the text. I saw the code from here StackOverflow my modification: extension String{ func gradient(x:CGFloat,y:CGFloat, fontSize:CGFloat)->UIImage{ let font:UIFont = UIFont.systemFontOfSize(fontSize) let name:String = NSFontAttributeName let textSize: CGSize = self.sizeWithAttributes([name:font]) let width:CGFloat = textSize.width // max 1024 due to Core Graphics limitations let height:CGFloat = textSize.height