uiprintinfo

Print a UIView, but NOT by rendering as a bitmap image

时间秒杀一切 提交于 2019-11-29 08:52:56
Say you have a simple UIView with only text (ie, UILabel) and maybe some black lines. Here's exactly how you can print that UIView... render it as a UIImage, and print that... - (IBAction)printB:(id)sender { // we want to print a normal view ... some UILabels, maybe a black line // in this technique, depressingly we CREATE AN IMAGE of the view... // step 1. make a UIImage, of the whole view. UIGraphicsBeginImageContextWithOptions(self.printMe.bounds.size, NO, 0.0); // [self.printMe.layer renderInContext:UIGraphicsGetCurrentContext()]; // UIImage *asAnImage =

Print a UIView, but NOT by rendering as a bitmap image

浪尽此生 提交于 2019-11-28 02:13:51
问题 Say you have a simple UIView with only text (ie, UILabel) and maybe some black lines. Here's exactly how you can print that UIView... render it as a UIImage, and print that... - (IBAction)printB:(id)sender { // we want to print a normal view ... some UILabels, maybe a black line // in this technique, depressingly we CREATE AN IMAGE of the view... // step 1. make a UIImage, of the whole view. UIGraphicsBeginImageContextWithOptions(self.printMe.bounds.size, NO, 0.0); // [self.printMe.layer