DKPhotoPickerImageView.m 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // PickerImageView.m
  3. // 相机
  4. //
  5. //
  6. #import "DKPhotoPickerImageView.h"
  7. @interface DKPhotoPickerImageView ()
  8. @property (nonatomic , weak) UIView *maskView;
  9. @property (nonatomic , weak) UIImageView *tickImageView;
  10. @property (nonatomic , weak) UIImageView *videoView;
  11. @end
  12. @implementation DKPhotoPickerImageView
  13. - (instancetype)initWithFrame:(CGRect)frame{
  14. if (self = [super initWithFrame:frame]) {
  15. self.contentMode = UIViewContentModeScaleAspectFill;
  16. self.clipsToBounds = YES;
  17. }
  18. return self;
  19. }
  20. - (UIView *)maskView{
  21. if (!_maskView) {
  22. UIView *maskView = [[UIView alloc] init];
  23. maskView.frame = self.bounds;
  24. maskView.backgroundColor = [UIColor whiteColor];
  25. maskView.alpha = 0.5;
  26. maskView.hidden = YES;
  27. [self addSubview:maskView];
  28. self.maskView = maskView;
  29. }
  30. return _maskView;
  31. }
  32. - (UIImageView *)videoView{
  33. if (!_videoView) {
  34. UIImageView *videoView = [[UIImageView alloc] initWithFrame:CGRectMake(10, self.bounds.size.height - 40, 30, 30)];
  35. videoView.image = [UIImage imageNamed:@"video"];
  36. videoView.contentMode = UIViewContentModeScaleAspectFit;
  37. [self addSubview:videoView];
  38. self.videoView = videoView;
  39. }
  40. return _videoView;
  41. }
  42. - (UIImageView *)tickImageView{
  43. if (!_tickImageView) {
  44. UIImageView *tickImageView = [[UIImageView alloc] init];
  45. tickImageView.frame = CGRectMake(self.bounds.size.width - 40, 0, 40, 40);
  46. tickImageView.image = [UIImage imageNamed:@"AssetsPickerChecked"];
  47. tickImageView.hidden = YES;
  48. [self addSubview:tickImageView];
  49. self.tickImageView = tickImageView;
  50. }
  51. return _tickImageView;
  52. }
  53. - (void)setIsVideoType:(BOOL)isVideoType{
  54. _isVideoType = isVideoType;
  55. self.videoView.hidden = !(isVideoType);
  56. }
  57. - (void)setMaskViewFlag:(BOOL)maskViewFlag{
  58. _maskViewFlag = maskViewFlag;
  59. self.maskView.hidden = !maskViewFlag;
  60. self.animationRightTick = maskViewFlag;
  61. }
  62. - (void)setMaskViewColor:(UIColor *)maskViewColor{
  63. _maskViewColor = maskViewColor;
  64. self.maskView.backgroundColor = maskViewColor;
  65. }
  66. - (void)setMaskViewAlpha:(CGFloat)maskViewAlpha{
  67. _maskViewAlpha = maskViewAlpha;
  68. self.maskView.alpha = maskViewAlpha;
  69. }
  70. - (void)setAnimationRightTick:(BOOL)animationRightTick{
  71. _animationRightTick = animationRightTick;
  72. self.tickImageView.hidden = !animationRightTick;
  73. }
  74. @end