|
|
@@ -15,6 +15,9 @@
|
|
|
@property (nonatomic) UIImage *image;
|
|
|
@property (nonatomic) UIScrollView *scrollView;
|
|
|
@property (nonatomic) UIImageView *imageView;
|
|
|
+@property (nonatomic) UITapGestureRecognizer *bgColorTapGesture;
|
|
|
+@property (nonatomic) NSInteger backgroundColorIndex;
|
|
|
+@property (nonatomic, readonly) NSArray<UIColor *> *backgroundColors;
|
|
|
@end
|
|
|
|
|
|
#pragma mark -
|
|
|
@@ -41,7 +44,9 @@
|
|
|
if (self) {
|
|
|
self.title = @"Preview";
|
|
|
self.image = image;
|
|
|
+ _backgroundColors = @[FLEXResources.checkerPatternColor, UIColor.whiteColor, UIColor.blackColor];
|
|
|
}
|
|
|
+
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
@@ -51,12 +56,10 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
- self.view.backgroundColor = [UIColor colorWithPatternImage:FLEXResources.checkerPattern];
|
|
|
-
|
|
|
self.imageView = [[UIImageView alloc] initWithImage:self.image];
|
|
|
self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
|
|
|
self.scrollView.delegate = self;
|
|
|
- self.scrollView.backgroundColor = self.view.backgroundColor;
|
|
|
+ self.scrollView.backgroundColor = self.backgroundColors.firstObject;
|
|
|
self.scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
|
[self.scrollView addSubview:self.imageView];
|
|
|
self.scrollView.contentSize = self.imageView.frame.size;
|
|
|
@@ -64,7 +67,14 @@
|
|
|
self.scrollView.maximumZoomScale = 2.0;
|
|
|
[self.view addSubview:self.scrollView];
|
|
|
|
|
|
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(actionButtonPressed:)];
|
|
|
+ self.bgColorTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeBackground)];
|
|
|
+ [self.scrollView addGestureRecognizer:self.bgColorTapGesture];
|
|
|
+
|
|
|
+ self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
|
|
|
+ initWithBarButtonSystemItem:UIBarButtonSystemItemAction
|
|
|
+ target:self
|
|
|
+ action:@selector(actionButtonPressed:)
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
- (void)viewDidLayoutSubviews {
|
|
|
@@ -97,6 +107,12 @@
|
|
|
self.scrollView.contentInset = UIEdgeInsetsMake(verticalInset, horizontalInset, verticalInset, horizontalInset);
|
|
|
}
|
|
|
|
|
|
+- (void)changeBackground {
|
|
|
+ self.backgroundColorIndex++;
|
|
|
+ self.backgroundColorIndex %= self.backgroundColors.count;
|
|
|
+ self.scrollView.backgroundColor = self.backgroundColors[self.backgroundColorIndex];
|
|
|
+}
|
|
|
+
|
|
|
- (void)actionButtonPressed:(id)sender {
|
|
|
static BOOL canSaveToCameraRoll = NO, didShowWarning = NO;
|
|
|
static dispatch_once_t onceToken;
|