ShowBtn.m 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // ShowBtn.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/2/26.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "ShowBtn.h"
  9. @implementation ShowBtn
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self) {
  14. }
  15. return self;
  16. }
  17. - (void)setLabelTitle:(NSString *)title
  18. {
  19. self.title = [NSString stringWithFormat:@" %@ ",title];
  20. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  21. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  22. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  23. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  24. [attStr appendAttributedString:collegeStr];
  25. [attStr appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
  26. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  27. }
  28. - (void)show
  29. {
  30. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  31. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  32. attach.image = [UIImage imageNamed:@"chatmsg_notice_hideAll_icon"];
  33. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  34. [attStr appendAttributedString:collegeStr];
  35. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  36. }
  37. - (void)dismiss
  38. {
  39. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  40. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  41. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  42. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  43. [attStr appendAttributedString:collegeStr];
  44. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  45. }
  46. @end