You can use UIImageView to draw strings.
However, it allows you to skip a subclass. And since I'm a bit prone to Core Graphics, it can still use it. You can just put it in - ViewDidLoad
UIGraphicsBeginImageContext(self.view.frame.size); [self.myImageView.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), brush); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 50, 50); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 200, 200); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); self.myImageView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
Addition to Rob's answer. For a quick third approach, you should use UIImageView - hide it - xib view. (This looks like the default UIImageView when dragging to xib in xcode 5)
Greetings and +1!
khunshan Aug 22 '14 at 6:43 2014-08-22 06:43
source share