diff --git a/BFRImageViewController/BFRImageContainerViewController.m b/BFRImageViewController/BFRImageContainerViewController.m index cbafa64..1e719c9 100644 --- a/BFRImageViewController/BFRImageContainerViewController.m +++ b/BFRImageViewController/BFRImageContainerViewController.m @@ -77,10 +77,10 @@ - (void)viewWillLayoutSubviews { //Scrollview [self.scrollView setFrame:self.view.bounds]; - //Set the aspect ration of the image + //Set the aspect ratio of the image float hfactor = self.imgLoaded.size.width / self.view.bounds.size.width; float vfactor = self.imgLoaded.size.height / self.view.bounds.size.height; - float factor = fmax(hfactor, vfactor); + float factor = fmax(hfactor, vfactor) < 1.0 ? 1.0 : fmax(hfactor, vfactor); //Divide the size by the greater of the vertical or horizontal shrinkage factor float newWidth = self.imgLoaded.size.width / factor; @@ -134,14 +134,6 @@ - (UIImageView *)createImageView { resizableImageView.contentMode = UIViewContentModeScaleAspectFill; resizableImageView.backgroundColor = [UIColor colorWithWhite:0 alpha:1]; - //Scale to keep its aspect ration - CGRect screenBound = [[UIScreen mainScreen] bounds]; - CGFloat screenWidth = screenBound.size.width; - CGFloat screenHeight = screenBound.size.height; - float scaleFactor = (self.imgLoaded ? self.imgLoaded.size.width : screenWidth) / screenWidth; - CGRect finalImageViewFrame = CGRectMake(0, (screenHeight/2)-((self.imgLoaded.size.height / scaleFactor)/2), screenWidth, self.imgLoaded.size.height / scaleFactor); - resizableImageView.layer.frame = finalImageViewFrame; - //Toggle UI controls UITapGestureRecognizer *singleImgTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissUI)]; singleImgTap.numberOfTapsRequired = 1; @@ -264,6 +256,7 @@ - (void)handleDrag:(UIPanGestureRecognizer *)recognizer { UIOffset centerOffset = UIOffsetMake(imgLocation.x - CGRectGetMidX(self.imgView.bounds), imgLocation.y - CGRectGetMidY(self.imgView.bounds)); + self.imgAttatchment = [[UIAttachmentBehavior alloc] initWithItem:self.imgView offsetFromCenter:centerOffset attachedToAnchor:location]; [self.animator addBehavior:self.imgAttatchment]; } else if (recognizer.state == UIGestureRecognizerStateChanged) { @@ -310,6 +303,7 @@ - (void)retrieveImageFromAsset { [self addImageToScrollView]; }]; } + - (void)retrieveImageFromURL { NSURL *url = (NSURL *)self.imgSrc; diff --git a/BFRImageViewerDemo/BFRImageViewer/Assets.xcassets/AppIcon.appiconset/Contents.json b/BFRImageViewerDemo/BFRImageViewer/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80..eeea76c 100644 --- a/BFRImageViewerDemo/BFRImageViewer/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/BFRImageViewerDemo/BFRImageViewer/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -59,6 +59,11 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : {