ShowBtn.m 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. //- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
  18. // CGRect bounds = self.bounds;
  19. // CGFloat widthDelta = self.bounds.size.width * 1.5;
  20. // bounds = CGRectInset(bounds, - 0.5 * widthDelta, 0);
  21. // return CGRectContainsPoint(bounds, point);
  22. //}
  23. - (void)setLabelTitle:(NSString *)title
  24. {
  25. self.title = [NSString stringWithFormat:@"%@ ",title];
  26. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  27. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  28. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  29. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  30. [attStr appendAttributedString:collegeStr];
  31. [attStr appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
  32. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  33. }
  34. - (void)show
  35. {
  36. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  37. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  38. attach.image = [UIImage imageNamed:@"chatmsg_notice_hideAll_icon"];
  39. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  40. [attStr appendAttributedString:collegeStr];
  41. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  42. }
  43. - (void)dismiss
  44. {
  45. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title.length == 0 ? @" " : self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17],NSForegroundColorAttributeName:UIColorHex(0x000000)}];
  46. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  47. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  48. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  49. [attStr appendAttributedString:collegeStr];
  50. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  51. }
  52. - (void)setcomTitle:(NSString *)title
  53. {
  54. self.title = [NSString stringWithFormat:@"%@ ",title];
  55. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title.length == 0 ? @" " : self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}];
  56. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  57. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  58. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  59. [attStr appendAttributedString:collegeStr];
  60. [attStr appendAttributedString:[[NSAttributedString alloc] initWithString:@" "]];
  61. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  62. }
  63. - (void)showCom
  64. {
  65. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}];
  66. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  67. attach.image = [UIImage imageNamed:@"chatmsg_notice_hideAll_icon"];
  68. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  69. [attStr appendAttributedString:collegeStr];
  70. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  71. }
  72. - (void)dismissCom
  73. {
  74. if (self.title.length == 0) {
  75. return;
  76. }
  77. NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:self.title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:UIColorHex(0x666666)}];
  78. NSTextAttachment *attach = [[NSTextAttachment alloc] init];
  79. attach.image = [UIImage imageNamed:@"chatmsg_notice_showAll_icon"];
  80. NSAttributedString *collegeStr = [NSAttributedString attributedStringWithAttachment:attach];
  81. [attStr appendAttributedString:collegeStr];
  82. [self setAttributedTitle:attStr forState:UIControlStateNormal];
  83. }
  84. @end