// // 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; } - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { CGRect bounds = self.bounds; CGFloat widthDelta = self.bounds.size.width * 1.5; bounds = CGRectInset(bounds, - 0.5 * widthDelta, 0); return CGRectContainsPoint(bounds, point); } - (void)setLabelTitle:(NSString *)title { self.title = [NSString stringWithFormat:@"%@ ",title]; NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],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:17],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.length == 0 ? @" " : self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],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]; } - (void)setcomTitle:(NSString *)title { self.title = [NSString stringWithFormat:@"%@ ",title]; NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title.length == 0 ? @" " : self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}]; 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)showCom { NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}]; 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)dismissCom { if (self.title.length == 0) { return; } NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}]; 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