1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-02 09:27:55 +01:00
Telegram/Telegraph/TGMusicPlayerModeButton.m
2016-02-25 01:03:51 +01:00

31 lines
1.0 KiB
Objective-C

#import "TGMusicPlayerModeButton.h"
@implementation TGMusicPlayerModeButton
- (void)drawRect:(CGRect)rect
{
if (self.selected)
{
static UIImage *selectionBackground = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^
{
UIGraphicsBeginImageContextWithOptions(CGSizeMake(12, 12), false, 0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, UIColorRGB(0xd0d0d0).CGColor);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 12, 12) cornerRadius:3.0f];
[path fill];
selectionBackground = [UIGraphicsGetImageFromCurrentImageContext() resizableImageWithCapInsets:UIEdgeInsetsMake(12.0f / 4.0f, 12.0f / 4.0f, 12.0f / 4.0f, 12.0f / 4.0f)];
UIGraphicsEndImageContext();
});
[selectionBackground drawInRect:self.bounds];
}
[super drawRect:rect];
}
@end