-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// EmojiImageView.h | ||
// UIKit Artwork Extractor | ||
// | ||
// Created by Cédric Luthi on 09.03.12. | ||
// Copyright (c) 2012 Cédric Luthi. All rights reserved. | ||
// | ||
|
||
@interface EmojiImageView : UIView | ||
|
||
- (id) initWithFrame:(CGRect)frame emoji:(id)emoji; | ||
|
||
- (UIImage *) image; | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// EmojiImageView.m | ||
// UIKit Artwork Extractor | ||
// | ||
// Created by Cédric Luthi on 09.03.12. | ||
// Copyright (c) 2012 Cédric Luthi. All rights reserved. | ||
// | ||
|
||
#import "EmojiImageView.h" | ||
|
||
@interface EmojiImageView () | ||
@property (nonatomic, retain) id emoji; | ||
@end | ||
|
||
@implementation EmojiImageView | ||
|
||
@synthesize emoji = _emoji; | ||
|
||
- (id) initWithFrame:(CGRect)frame emoji:(id)emoji | ||
{ | ||
if (!(self = [super initWithFrame:frame])) | ||
return nil; | ||
|
||
self.backgroundColor = [UIColor clearColor]; | ||
self.emoji = emoji; | ||
|
||
return self; | ||
} | ||
|
||
- (void) dealloc | ||
{ | ||
self.emoji = nil; | ||
[super dealloc]; | ||
} | ||
|
||
- (void) drawRect:(CGRect)rect | ||
{ | ||
UIFont *emojiFont = [UIFont fontWithName:@"AppleColorEmoji" size:CGRectGetHeight(self.frame)]; | ||
NSString *emojiString = [self.emoji valueForKey:@"emojiString"]; | ||
[emojiString drawAtPoint:CGPointZero withFont:emojiFont]; | ||
} | ||
|
||
- (UIImage *) image | ||
{ | ||
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0f); | ||
CGContextRef context = UIGraphicsGetCurrentContext(); | ||
[self.layer renderInContext:context]; | ||
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | ||
UIGraphicsEndImageContext(); | ||
|
||
return image; | ||
} | ||
|
||
@end |
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
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