Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom image scaling in done button #204

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/IDMPhotoBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@property (nonatomic) BOOL useWhiteBackgroundColor;
@property (nonatomic, weak) UIImage *doneButtonImage;
@property (nonatomic, weak) UIColor *trackTintColor, *progressTintColor;
@property (nonatomic, weak) UIColor *actionButtonColor;

@property (nonatomic, weak) UIImage *scaleImage;

Expand Down
6 changes: 5 additions & 1 deletion Classes/IDMPhotoBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ @implementation IDMPhotoBrowser
@synthesize actionsSheet = _actionsSheet, activityViewController = _activityViewController;
@synthesize trackTintColor = _trackTintColor, progressTintColor = _progressTintColor;
@synthesize delegate = _delegate;
@synthesize actionButtonColor = _actionButtonColor;

#pragma mark - NSObject

Expand Down Expand Up @@ -611,7 +612,7 @@ - (void)viewDidLoad {
}
else {
[_doneButton setImage:_doneButtonImage forState:UIControlStateNormal];
_doneButton.contentMode = UIViewContentModeScaleAspectFit;
_doneButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
}

UIImage *leftButtonImage = (_leftArrowImage == nil) ?
Expand Down Expand Up @@ -658,6 +659,9 @@ - (void)viewDidLoad {
target:self
action:@selector(actionButtonPressed:)];

if (_actionButtonColor) {
_actionButton.tintColor = _actionButtonColor;
}
// Gesture
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognized:)];
[_panGesture setMinimumNumberOfTouches:1];
Expand Down
29 changes: 18 additions & 11 deletions Classes/IDMZoomingScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,20 @@ - (void)setMaxMinZoomScalesForCurrentBounds {
//minScale = 1.0;
}

// Calculate Max
CGFloat maxScale = 4.0; // Allow double scale
// on high resolution screens we have double the pixel density, so we will be seeing every pixel if we limit the
// maximum zoom scale to 0.5.
if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
maxScale = maxScale / [[UIScreen mainScreen] scale];

if (maxScale < minScale) {
maxScale = minScale * 2;
}
}
// // Calculate Max
// CGFloat maxScale = 4.0; // Allow double scale
// // on high resolution screens we have double the pixel density, so we will be seeing every pixel if we limit the
// // maximum zoom scale to 0.5.
// if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
// maxScale = maxScale / [[UIScreen mainScreen] scale];
//
// if (maxScale < minScale) {
// maxScale = minScale * 2;
// }
// }
//

CGFloat maxScale = minScale * 2.3;
// Set
self.maximumZoomScale = maxScale;
self.minimumZoomScale = minScale;
Expand Down Expand Up @@ -258,6 +260,11 @@ - (void)scrollViewDidZoom:(UIScrollView *)scrollView {
[self layoutIfNeeded];
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
NSLog(@"****");
NSLog(@"currentZoomScale: %f", scale);
NSLog(@"****");
}
#pragma mark - Tap Detection

- (void)handleSingleTap:(CGPoint)touchPoint {
Expand Down