fixed scrolling performance, result of adding padding to the displayed image.

This commit is contained in:
suzuki_keishi 2016-09-16 11:06:06 +09:00
parent c3f8fa7e8a
commit 464114e40d
4 changed files with 27 additions and 17 deletions

View File

@ -1,5 +1,12 @@
# Change Log
## 3.1.2
Released on 16-9-2016
#### Fixed
- Scrolling performance slowed #145
## 3.1.1
Released on 15-9-2016

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SKPhotoBrowser"
s.version = "3.1.1"
s.version = "3.1.2"
s.summary = "Simple PhotoBrowser/Viewer inspired by facebook, twitter photo browsers written by swift2.0."
s.homepage = "https://github.com/suzuki-0000/SKPhotoBrowser"
s.license = { :type => "MIT", :file => "LICENSE" }

View File

@ -30,13 +30,14 @@ public struct SKPhotoBrowserOptions {
public static var enableZoomBlackArea: Bool = true
public static var enableSingleTapDismiss: Bool = false
public static var imagePaddingX: CGFloat = 0
public static var imagePaddingY: CGFloat = 0
public static var backgroundColor = UIColor.blackColor()
public static var textAndIconColor = UIColor.whiteColor()
public static var toolbarTextShadowColor = UIColor.darkTextColor()
public static var toolbarFont = UIFont(name: "Helvetica", size: 16.0)
public static var captionFont = UIFont.systemFontOfSize(17.0)
}
// FIXED: Scrolling performance slowed #145
// public static var imagePaddingX: CGFloat = 0
// public static var imagePaddingY: CGFloat = 0
}

View File

@ -183,20 +183,22 @@ public class SKZoomingScrollView: UIScrollView {
if let image = photo.underlyingImage {
// FIXED: Scrolling performance slowed #145
// create padding
let width: CGFloat = image.size.width + SKPhotoBrowserOptions.imagePaddingX
let height: CGFloat = image.size.height + SKPhotoBrowserOptions.imagePaddingY;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), false, 0.0);
let context: CGContextRef = UIGraphicsGetCurrentContext()!;
UIGraphicsPushContext(context);
let origin: CGPoint = CGPointMake((width - image.size.width) / 2, (height - image.size.height) / 2);
image.drawAtPoint(origin)
UIGraphicsPopContext();
let imageWithPadding = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// let width: CGFloat = image.size.width + SKPhotoBrowserOptions.imagePaddingX
// let height: CGFloat = image.size.height + SKPhotoBrowserOptions.imagePaddingY;
// UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), false, 0.0);
// let context: CGContextRef = UIGraphicsGetCurrentContext()!;
// UIGraphicsPushContext(context);
// let origin: CGPoint = CGPointMake((width - image.size.width) / 2, (height - image.size.height) / 2);
// image.drawAtPoint(origin)
// UIGraphicsPopContext();
// let imageWithPadding = UIGraphicsGetImageFromCurrentImageContext();
// UIGraphicsEndImageContext();
// image
photoImageView.image = imageWithPadding
photoImageView.image = image
photoImageView.contentMode = photo.contentMode
photoImageView.backgroundColor = SKPhotoBrowserOptions.backgroundColor
@ -336,4 +338,4 @@ private extension SKZoomingScrollView {
return CGRect(x: x, y: y, width: w, height: h)
}
}
}