先看一下实现效果如下图:
具体实现代码如下:
View视图的创建
#import <UIKit/UIKit.h>
@protocol PhotoViewDelegate <NSObject>
-(void)addPhotoLessThanMax:(NSInteger)num;//添加图片
-(void)deletePhotoTap:(NSInteger)tag;//删除图片
@end
typedef void (^PhotoBlock)(BOOL isBool);
@interface PhotoView : UIView<UIGestureRecognizerDelegate>
@property (assign, nonatomic) id <PhotoViewDelegate>delegate;
@property (strong, nonatomic)NSMutableArray *imgArray;
@property(nonatomic,copy)PhotoBlock inputBlock;
- (instancetype)initWithFrame:(CGRect)frame;
@end
#import "PhotoView.h"
#import "UIImage+GIF.h"
#define BIGIMAGE_WIDTH (ScreenWidth-70)/3*2+10
#define DIVIDE_WIDTH 10
#define SMALLIMAGE_WIDTH (ScreenWidth-70)/3
#define MOVEIMAGE_WIDTH SMALLIMAGE_WIDTH * 10
@interface PhotoView()
@property (strong, nonatomic)UIImageView *moveImageView;
@property (nonatomic,strong)NSMutableArray *viewArray;
@property (nonatomic,strong)NSMutableArray * btnAray;
@property (nona