Created
May 17, 2015 03:51
-
-
Save haojianzong/35619027a1e60754cf99 to your computer and use it in GitHub Desktop.
A Category to Set LocalizedString for Xib Files in User Define Runtime Attributes
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
// | |
// UIView+JZLocalizedIB.m | |
// | |
// Created by haojianzong on 12/5/17. | |
// | |
// A Category to Set LocalizedString for Xib Files in User Define Runtime Attributes | |
#import <UIKit/UIKit.h> | |
#import "JZLocaleUtils.h" | |
@interface UIButton (JZLocalizedIB) | |
@property (nonatomic, copy) NSString* localizedString; | |
@end | |
@implementation UIButton (JZLocalizedIB) | |
- (NSString *)localizedString { | |
return self.titleLabel.text; | |
} | |
- (void)setLocalizedString:(NSString *)localizedString { | |
[self setTitle:[JZLocaleUtils localizedString:localizedString] | |
forState:UIControlStateNormal]; | |
} | |
@end | |
@interface UILabel (JZLocalizedIB) | |
@property (nonatomic, copy) NSString* localizedString; | |
@end | |
@implementation UILabel (JZLocalizedIB) | |
- (NSString *)localizedString { | |
return self.text; | |
} | |
- (void)setLocalizedString:(NSString *)localizedString { | |
self.text = [JZLocaleUtils localizedString:localizedString]; | |
} | |
@end | |
@interface UITextField (JZLocalizedIB) | |
@property (nonatomic, copy) NSString* localizedString; | |
@end | |
@implementation UITextField (JZLocalizedIB) | |
- (NSString *)localizedString { | |
return self.text; | |
} | |
- (void)setLocalizedString:(NSString *)localizedString { | |
self.text = [JZLocaleUtils localizedString:localizedString]; | |
} | |
@end | |
@interface UITextView (JZLocalizedIB) | |
@property (nonatomic, copy) NSString* localizedString; | |
@end | |
@implementation UITextView (JZLocalizedIB) | |
- (NSString *)localizedString { | |
return self.text; | |
} | |
- (void)setLocalizedString:(NSString *)localizedString { | |
self.text = [JZLocaleUtils localizedString:localizedString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment