// // ShowBtn.m // smartRhino // // Created by niuzhen on 2020/2/26. // Copyright © 2020 tederen. All rights reserved. // #import "ShowBtn.h" @implementation ShowBtn - (instancetype)init { self = [super init]; if (self) { } return self; } - (void)setLabelTitle:(NSString *)title { self.title = [NSString stringWithFormat:@" %@ ",title]; NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}]; NSTextAttachment *attach = [[NSTextAttachment alloc] init]; attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"]; NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach]; [attStr appendAttributedString:collegeStr]; [attStr appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]]; [self setAttributedTitle:attStr forState:UIControlStateNormal]; } - (void)show { NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}]; NSTextAttachment *attach = [[NSTextAttachment alloc] init]; attach.image = [UIImage imageNamed:@"chatmsg_notice_hideAll_icon"]; NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach]; [attStr appendAttributedString:collegeStr]; [self setAttributedTitle:attStr forState:UIControlStateNormal]; } - (void)dismiss { NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}]; NSTextAttachment *attach = [[NSTextAttachment alloc] init]; attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"]; NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach]; [attStr appendAttributedString:collegeStr]; [self setAttributedTitle:attStr forState:UIControlStateNormal]; } @end