Guest User

Untitled

a guest
Sep 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. + (UIImage *)nowPlayingButton {
  2.    
  3.     UILabel * addCustomLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 25)];
  4.     addCustomLabel.text = NSLocalizedString(@"NOW_PLAYING_NEWLINE", @"Now playing text divided on two lines");
  5.     addCustomLabel.textColor = [UIColor whiteColor];
  6.     addCustomLabel.font = [UIFont boldSystemFontOfSize:10];
  7.     addCustomLabel.numberOfLines = 2;
  8.     addCustomLabel.backgroundColor = [UIColor clearColor];
  9.     addCustomLabel.textAlignment = UITextAlignmentCenter;
  10.    
  11.     CGSize size = addCustomLabel.bounds.size;
  12.    
  13.     UIGraphicsBeginImageContext(size);
  14.     CGContextRef context = UIGraphicsGetCurrentContext();
  15.     [addCustomLabel.layer renderInContext: context];
  16.     CGImageRef imageRef = CGBitmapContextCreateImage(context);
  17.     UIImage *img = [UIImage imageWithCGImage: imageRef];
  18.     CGImageRelease(imageRef);
  19.     CGContextRelease(context);
  20.  
  21.    
  22.     return img;
  23. }
Add Comment
Please, Sign In to add comment