| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // RootModeCell.m
- // RA Image
- //
- // Created by Jack on 2017/5/2.
- // Copyright © 2017年 USAI. All rights reserved.
- //
- #import "RootModeCell.h"
- @interface RootModeCell ()
- @property (strong, nonatomic) IBOutlet UILabel *modeLabel;
- @end
- @implementation RootModeCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setMode:(NSString *)mode {
- _mode = mode;
- self.modeLabel.text = mode;
- }
- - (void)setEnable:(BOOL)enable {
- _enable = enable;
- self.modeLabel.enabled = enable;
- }
- - (void)setMode:(NSString *)mode desc:(NSString *)desc {
- _mode = mode;
- _desc = desc;
- // _desc = @"dfhajkdhfkajhdklahdfalllllllalalalalaPKOSdididiididdi";
- self.modeLabel.attributedText = nil;
- self.modeLabel.text = nil;
- if (desc == nil || desc.length == 0) {
- self.modeLabel.text = mode;
- } else if (mode == nil || mode.length == 0){
- self.modeLabel.text = mode;
- } else {
- NSString *str = [NSString stringWithFormat:@"%@ -- %@",_mode,_desc];
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:str];
- NSRange redRange = NSMakeRange(_mode.length + 1, str.length - (_mode.length + 1));
- NSRange normalRange = NSMakeRange(0, _mode.length);
- NSDictionary *redAttrs = @{
- NSForegroundColorAttributeName : [UIColor redColor],
- NSFontAttributeName : [UIFont systemFontOfSize:15.0f]
- };
- NSDictionary *normalAttrs = @{
- NSForegroundColorAttributeName : [UIColor blackColor],
- NSFontAttributeName : [UIFont systemFontOfSize:17.0f]
- };
- [attrStr addAttributes:redAttrs range:redRange];
- [attrStr addAttributes:normalAttrs range:normalRange];
- self.modeLabel.attributedText = attrStr;
- }
- }
- @end
|