GoodWritUpImgV.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // GoodWritUpImgV.m
  3. // westkissMob
  4. //
  5. // Created by 王猛 on 2022/10/6.
  6. //
  7. #import "GoodWritUpImgV.h"
  8. @implementation GoodWritUpImgV
  9. /*
  10. // Only override drawRect: if you perform custom drawing.
  11. // An empty implementation adversely affects performance during animation.
  12. - (void)drawRect:(CGRect)rect {
  13. // Drawing code
  14. }
  15. */
  16. - (instancetype)initWithFrame:(CGRect)frame{
  17. self = [super initWithFrame:frame];
  18. if(self){
  19. self.layer.cornerRadius = 4;
  20. self.userInteractionEnabled = YES;
  21. [self addSubview:self.closeBtn];
  22. self.closeBtn.frame = CGRectMake(frame.size.width-22,0 , 22, 22);
  23. }
  24. return self;
  25. }
  26. -(UIButton *)closeBtn{
  27. if(!_closeBtn){
  28. _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  29. _closeBtn.backgroundColor = [UIColor colorWithHexString:@"#0B0B0B" Alpha:0.6];
  30. [_closeBtn setTitle:@"X" forState:UIControlStateNormal];
  31. _closeBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  32. [_closeBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
  33. }
  34. return _closeBtn;
  35. }
  36. - (void)setIsCanTap:(BOOL)isCanTap{
  37. _isCanTap = isCanTap;
  38. if(isCanTap){
  39. self.closeBtn.hidden = YES;
  40. }else{
  41. self.closeBtn.hidden = NO;
  42. }
  43. }
  44. @end