YMCaptchaTextSecrectImageView.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // YMCaptchaTextSecrectImageView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2023/5/5.
  6. //
  7. #import "YMCaptchaTextSecrectImageView.h"
  8. @interface YMCaptchaTextSecrectImageView()
  9. {
  10. UIImageView *_lockImgView;
  11. }
  12. @end
  13. @implementation YMCaptchaTextSecrectImageView
  14. - (instancetype)init{
  15. if (self = [super init]) {
  16. [self createUI];
  17. }
  18. return self;
  19. }
  20. - (void)createUI{
  21. _lockImgView = [[UIImageView alloc]init];
  22. _lockImgView.contentMode = UIViewContentModeScaleAspectFill;
  23. _lockImgView.image = [UIImage imageNamed:@"smallLock"];
  24. [self addSubview:_lockImgView];
  25. [_lockImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerX.offset(0);
  27. make.centerY.offset(0);
  28. make.width.height.mas_equalTo(24);
  29. }];
  30. }
  31. #pragma mark - Setter & Getter
  32. - (void)setImage:(UIImage *)image{
  33. _image = image;
  34. _lockImgView.image = image;
  35. }
  36. - (void)setImageWidth:(CGFloat)imageWidth{
  37. _imageWidth = imageWidth;
  38. [_lockImgView mas_updateConstraints:^(MASConstraintMaker *make) {
  39. make.width.mas_equalTo(imageWidth);
  40. }];
  41. }
  42. - (void)setImageHeight:(CGFloat)imageHeight{
  43. _imageHeight = imageHeight;
  44. [_lockImgView mas_updateConstraints:^(MASConstraintMaker *make) {
  45. make.height.mas_equalTo(imageHeight);
  46. }];
  47. }
  48. @end