1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-02 17:38:07 +01:00
Telegram/Telegraph/TGSharedMediaMusicEmptyView.m

56 lines
1.8 KiB
Mathematica
Raw Normal View History

2016-02-25 01:03:51 +01:00
#import "TGSharedMediaMusicEmptyView.h"
#import "TGFont.h"
#import "TGImageUtils.h"
@interface TGSharedMediaMusicEmptyView () {
UIImageView *_iconView;
UILabel *_textLabel;
}
@end
@implementation TGSharedMediaMusicEmptyView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil)
{
_iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SharedMediaEmptyMusicIcon.png"]];
[self addSubview:_iconView];
_textLabel = [[UILabel alloc] init];
_textLabel.backgroundColor = [UIColor clearColor];
_textLabel.textColor = UIColorRGB(0x999999);
_textLabel.font = TGSystemFontOfSize(16.0f);
_textLabel.text = TGLocalized(@"SharedMedia.EmptyMusicText");
_textLabel.textAlignment = NSTextAlignmentCenter;
_textLabel.numberOfLines = 0;
_textLabel.lineBreakMode = NSLineBreakByWordWrapping;
[self addSubview:_textLabel];
}
return self;
}
- (void)layoutItems
{
CGSize boundsSize = CGSizeMake(self.bounds.size.width - 20.0f, CGFLOAT_MAX);
CGSize iconSize = _iconView.image.size;
CGSize textSize = [_textLabel sizeThatFits:boundsSize];
CGFloat anchor = 3.0f + (self.bounds.size.width < self.bounds.size.height ? 0.0f : 50.0f);
_iconView.frame = CGRectMake(CGFloor((self.bounds.size.width - iconSize.width) / 2.0f), CGFloor(self.bounds.size.height / 2.0f) + 3.0f + anchor + TGRetinaPixel - iconSize.height - 28.0f, iconSize.width, iconSize.height);
_textLabel.frame = CGRectMake(CGFloor((self.bounds.size.width - textSize.width) / 2.0f), CGFloor(self.bounds.size.height / 2.0f) - 2.0f + anchor, textSize.width, textSize.height);
}
- (void)layoutSubviews
{
[super layoutSubviews];
[self layoutItems];
}
@end