Welcome to mirror list, hosted at ThFree Co, Russian Federation.

UIButton+RuntimeAttributes.m « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3b3924ca3a58264b150be215a666bcc5b25b7deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
//  UIButton+RuntimeAttributes.m
//  Maps
//
//  Created by Ilya Grechuhin on 09.07.15.
//  Copyright (c) 2015 MapsWithMe. All rights reserved.
//

#import "Macros.h"
#import "UIButton+RuntimeAttributes.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
#import "UIKitCategories.h"

@implementation UIButton (RuntimeAttributes)

- (void)setLocalizedText:(NSString *)localizedText {
  [self setTitle:L(localizedText) forState:UIControlStateNormal];
}

- (NSString *)localizedText {
  return L([self titleForState:UIControlStateNormal]);
}

- (void)setFontName:(NSString *)fontName
{
  self.titleLabel.font = [UIFont fontWithName:fontName];
}

- (void)setTextColorName:(NSString *)colorName
{
  [self setTitleColor:[UIColor colorWithName:colorName] forState:UIControlStateNormal];
}

- (void)setTextColorHighlightedName:(NSString *)colorName
{
  [self setTitleColor:[UIColor colorWithName:colorName] forState:UIControlStateHighlighted];
}

- (void)setBackgroundColorName:(NSString *)colorName
{
  [self setBackgroundColor:[UIColor colorWithName:colorName] forState:UIControlStateNormal];
}

- (void)setBackgroundHighlightedColorName:(NSString *)colorName
{
  [self setBackgroundColor:[UIColor colorWithName:colorName] forState:UIControlStateHighlighted];
}

- (void)setBackgroundColor:(UIColor *)color forState:(UIControlState)state
{
  [self setBackgroundImage:[UIImage imageWithColor:color] forState:state];
}

@end