Created
October 4, 2015 03:09
-
-
Save erichsu/35cf566d0836166a7a03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)drawImage:(UIImage *)profileImage withBadge:(UIImage *)badge withText:(NSString *)count { | |
UIGraphicsBeginImageContextWithOptions(profileImage.size, NO, 0.0f); | |
[profileImage drawInRect:CGRectMake(0, 0, profileImage.size.width, profileImage.size.height)]; | |
[badge drawInRect:CGRectMake(profileImage.size.width - badge.size.width, 0, badge.size.width, badge.size.height)]; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, badge.size.width, badge.size.height)]; | |
label.text = count; | |
label.textAlignment = NSTextAlignmentCenter; | |
label.font = [UIFont systemFontOfSize:11.f]; | |
label.textColor = [UIColor whiteColor]; | |
[label drawTextInRect:CGRectMake(profileImage.size.width - badge.size.width, 0, badge.size.width, badge.size.height)]; | |
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return resultImage; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment