1
0
mirror of https://github.com/danog/Telegram.git synced 2024-12-04 10:27:46 +01:00
Telegram/legacy/TelegraphKit/TGModernToolbarButton.m
2015-10-01 19:19:52 +03:00

59 lines
1.4 KiB
Objective-C

#import "TGModernToolbarButton.h"
#import "TGFont.h"
@implementation TGModernToolbarButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
_buttonTitleLabel = [[UILabel alloc] init];
_buttonTitleLabel.textColor = [UIColor whiteColor];
_buttonTitleLabel.backgroundColor = [UIColor clearColor];
_buttonTitleLabel.font = TGSystemFontOfSize(17);
[self addSubview:_buttonTitleLabel];
[self setTitleColor:[UIColor whiteColor]];
}
return self;
}
- (void)sizeToFit
{
[self.buttonTitleLabel sizeToFit];
CGRect frame = self.frame;
frame.size.height = self.buttonTitleLabel.frame.size.height;
frame.size.width = self.buttonTitleLabel.frame.size.width;
self.frame = frame;
}
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)state
{
[super setTitleColor:color forState:state];
if (state == UIControlStateNormal)
{
_buttonTitleLabel.textColor = color;
}
}
- (void)setButtonTitle:(NSString *)buttonTitle
{
_buttonTitle = buttonTitle;
_buttonTitleLabel.text = buttonTitle;
[_buttonTitleLabel sizeToFit];
}
- (void)layoutSubviews
{
[super layoutSubviews];
//_buttonTitleLabel.frame = CGRectMake(0.0f, 0.0f, _buttonTitleLabel.frame.size.width, _buttonTitleLabel.frame.size.height);
}
@end