Compare commits

...

14 Commits

Author SHA1 Message Date
Grigory Ulanov e87ec9eb72 black color 2016-10-11 11:53:12 +03:00
Grigory Ulanov 2db02eecc0 text color changed 2016-10-11 11:15:08 +03:00
Grigory Ulanov d40c5d2c2e navigationBar added 2016-10-10 16:47:04 +03:00
Grigory Ulanov 5714a95908 full view controller swipe fade 2016-09-21 16:29:37 +03:00
keishi suzuki 8d2c1f3b38 Merge pull request #146 from suzuki-0000/bugfix/#145
fixed scrolling performance, result of adding padding to the displaye…
2016-09-16 11:06:54 +09:00
suzuki_keishi 464114e40d fixed scrolling performance, result of adding padding to the displayed image. 2016-09-16 11:06:06 +09:00
suzuki_keishi c3f8fa7e8a update change log. 2016-09-15 16:12:03 +09:00
suzuki_keishi 3b275293b5 update pod spec and changelog. 2016-09-15 16:06:48 +09:00
suzuki_keishi 6a591bcd5d Merge branch 'master' of github.com:suzuki-0000/SKPhotoBrowser into feature/#144 2016-09-15 16:05:31 +09:00
suzuki_keishi 26378bae91 crash in exapmle in xcode8 fixed. 2016-09-15 16:05:20 +09:00
keishi suzuki 709f024135 Merge pull request #144 from appsunited/master
Provides various UI configuration options via SKPhotoBrowserOptions
2016-09-15 16:04:37 +09:00
keishi suzuki 49131da2e0 update readme 2016-09-14 11:43:06 +09:00
Felix Weiss 1704f37363 Provides various UI configuration options via SKPhotoBrowserOptions like padding for images and color customizations. 2016-09-14 02:15:15 +02:00
keishi suzuki 554dac6756 update readme 2016-09-12 13:35:30 +09:00
16 changed files with 216 additions and 44 deletions

View File

@ -1,5 +1,20 @@
# Change Log
## 3.1.2
Released on 16-9-2016
#### Fixed
- Scrolling performance slowed #145
## 3.1.1
Released on 15-9-2016
#### Fixed
- Example crash in xcode8 fixed
- Provides various UI configuration options via SKPhotoBrowserOptions. #144
## 3.1.0
Released on 9-2016
@ -7,7 +22,7 @@ Released on 9-2016
#### Fixed
- Issue with multiple actionButtonTitles #137
- fix swiftlint warnings #140
- Update for Xcode GM. #141
- Update for Xcode 8 GM (swift 2.3). #141
## 3.0.2
@ -16,7 +31,7 @@ Released on 9-2016
#### Fixed
- Issue with multiple actionButtonTitles #137
- Impossible to zoom when resolution is 1024x768 #134
- unexpectedly found nil while unwrapping an Optional value #133
- Crash bug at zooming scrool view #133
## 3.0.1

View File

@ -1,6 +1,7 @@
SKPhotoBrowser
========================
![Language](https://img.shields.io/badge/language-Swift%202.3-orange.svg)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SKPhotoBrowser.svg?style=flat)](http://cocoadocs.org/docsets/SKPhotoBrowser)
@ -106,14 +107,39 @@ func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath i
You can customize Toolbar via SKPhotoBrowserOptions.
```swift
SKPhotoBrowserOptions.displayToolbar = false // all tool bar will be hidden
SKPhotoBrowserOptions.displayCounterLabel = false // counter label will be hidden
SKPhotoBrowserOptions.displayBackAndForwardButton = false // back / forward button will be hidden
SKPhotoBrowserOptions.displayAction = false // action button will be hidden
SKPhotoBrowserOptions.displayDeleteButton = true // delete button will be shown
SKPhotoBrowserOptions.displayToolbar = false // all tool bar will be hidden
SKPhotoBrowserOptions.displayCounterLabel = false // counter label will be hidden
SKPhotoBrowserOptions.displayBackAndForwardButton = false // back / forward button will be hidden
SKPhotoBrowserOptions.displayAction = false // action button will be hidden
SKPhotoBrowserOptions.displayDeleteButton = true // delete button will be shown
SKPhotoBrowserOptions.displayHorizontalScrollIndicator = false // horizontal scroll bar will be hidden
SKPhotoBrowserOptions.displayVerticalScrollIndicator = false // vertical scroll bar will be hidden
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
```
#### Colors
You can customize text, icon and background colors via SKPhotoBrowserOptions
```swift
SKPhotoBrowserOptions.backgroundColor = UIColor.whiteColor() // browser view will be white
SKPhotoBrowserOptions.textAndIconColor = UIColor.blackColor() // text and icons will be black
SKPhotoBrowserOptions.toolbarTextShadowColor = UIColor.clearColor() // shadow of toolbar text will be removed
SKPhotoBrowserOptions.toolbarFont = UIFont(name: "Futura", size: 16.0) // font of toolbar will be 'Futura'
SKPhotoBrowserOptions.captionFont = UIFont(name: "Helvetica", size: 18.0) // font of toolbar will be 'Helvetica'
```
#### Images
You can customize the padding of displayed images via SKPhotoBrowserOptions
```swift
SKPhotoBrowserOptions.imagePaddingX = 50 // image padding left and right will be 25
SKPhotoBrowserOptions.imagePaddingY = 50 // image padding top and bottom will be 25
```
#### Statusbar
You can customize the visibility of the Statusbar in browser view via SKPhotoBrowserOptions
```swift
SKPhotoBrowserOptions.displayStatusbar = false // status bar will be hidden
```
#### Custom Cache From Web URL
You can use SKCacheable protocol if others are adaptable. (SKImageCacheable or SKRequestResponseCacheable)
@ -130,8 +156,8 @@ SKCache.sharedCache.imageCache = CustomImageCache()
#### CustomButton Image
Close, Delete buttons are able to change image and frame.
``` swift
browser.browser.updateCloseButton(UIImage())
browser.browser.updateUpdateButton(UIImage())
browser.updateCloseButton(UIImage())
browser.updateUpdateButton(UIImage())
```
#### Delete Photo
@ -149,8 +175,7 @@ images.append(photo)
#### SwipeGesture
vertical swipe can enable/disable:
``` swift
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
browser.disableVerticalSwipe = true
SKPhotoBrowserOptions.disableVerticalSwipe = true
```
#### Delegate
@ -183,10 +208,12 @@ func didDismissAtPageIndex(index: Int) {
```
#### Minor Option
- blackArea handling which is appearing outside of photo
#### Options
You can access via `SKPhotoBrowserOptions`, which can use for browser control.
- single tap handling, dismiss/noaction
- blackArea handling which is appearing outside of photo
- bounce animation when appearing/dismissing
- text color, font, or more
``` swift
SKPhotoBrowserOptions.enableZoomBlackArea = true // default true
SKPhotoBrowserOptions.enableSingleTapDismiss = true // default false

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SKPhotoBrowser"
s.version = "3.1.0"
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

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
0AE527521DABB87500619FAD /* SKNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AE527511DABB87500619FAD /* SKNavigationBar.swift */; };
210E53ED1C986D3A008DD5E3 /* UIView+Radius.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210E53EC1C986D3A008DD5E3 /* UIView+Radius.swift */; };
210E53EF1C986D57008DD5E3 /* UIImage+Rotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 210E53EE1C986D57008DD5E3 /* UIImage+Rotation.swift */; };
26C97AD51D0EB6870039F6CB /* SKCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26C97AD41D0EB6870039F6CB /* SKCache.swift */; };
@ -44,6 +45,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0AE527511DABB87500619FAD /* SKNavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKNavigationBar.swift; sourceTree = "<group>"; };
210E53EC1C986D3A008DD5E3 /* UIView+Radius.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIView+Radius.swift"; path = "extensions/UIView+Radius.swift"; sourceTree = "<group>"; };
210E53EE1C986D57008DD5E3 /* UIImage+Rotation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UIImage+Rotation.swift"; path = "extensions/UIImage+Rotation.swift"; sourceTree = "<group>"; };
26C97AD41D0EB6870039F6CB /* SKCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SKCache.swift; sourceTree = "<group>"; };
@ -136,6 +138,7 @@
8909B5411BC791510060A053 /* SKPhotoBrowser.swift */,
89C24A811D657AD1005F09A9 /* SKPhotoBrowserOptions.swift */,
890A6F1F1D5D9E53003B01F0 /* SKToolbar.swift */,
0AE527511DABB87500619FAD /* SKNavigationBar.swift */,
8909B5331BC791280060A053 /* SKPhotoBrowser.h */,
8917B1AF1D5A13DE000CE1C4 /* SKPhotoBrowserDelegate.swift */,
89D0BA481D59966B002A811B /* SKMesurement.swift */,
@ -300,6 +303,7 @@
8917B1B41D5A14B0000CE1C4 /* SKButtons.swift in Sources */,
89C24A821D657AD1005F09A9 /* SKPhotoBrowserOptions.swift in Sources */,
26C97AD51D0EB6870039F6CB /* SKCache.swift in Sources */,
0AE527521DABB87500619FAD /* SKNavigationBar.swift in Sources */,
210E53EF1C986D57008DD5E3 /* UIImage+Rotation.swift in Sources */,
8909B5431BC791510060A053 /* SKCaptionView.swift in Sources */,
8909B5491BC791510060A053 /* SKPhotoBrowser.swift in Sources */,

View File

@ -157,6 +157,8 @@ private extension SKAnimator {
self.resizableImageView?.frame = self.finalImageViewFrame
},
completion: { (Bool) -> Void in
UIApplication.sharedApplication().setStatusBarHidden(!SKPhotoBrowserOptions.displayStatusbar, withAnimation: .Fade)
browser.view.hidden = false
browser.view.alpha = 1.0
browser.backgroundView.hidden = true

View File

@ -27,13 +27,14 @@ class SKButton: UIButton {
func setup(imageName: String) {
backgroundColor = .clearColor()
tintColor = SKPhotoBrowserOptions.textAndIconColor
imageEdgeInsets = insets
// clipsToBounds = true
translatesAutoresizingMaskIntoConstraints = true
autoresizingMask = [.FlexibleBottomMargin, .FlexibleLeftMargin, .FlexibleRightMargin, .FlexibleTopMargin]
let image = UIImage(named: "SKPhotoBrowser.bundle/images/\(imageName)",
inBundle: bundle, compatibleWithTraitCollection: nil) ?? UIImage()
inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) ?? UIImage()
setImage(image, forState: .Normal)
}

View File

@ -61,13 +61,13 @@ private extension SKCaptionView {
photoLabel.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
photoLabel.opaque = false
photoLabel.backgroundColor = .clearColor()
photoLabel.textColor = .whiteColor()
photoLabel.textColor = SKPhotoBrowserOptions.textAndIconColor
photoLabel.textAlignment = .Center
photoLabel.lineBreakMode = .ByTruncatingTail
photoLabel.numberOfLines = 3
photoLabel.shadowColor = UIColor(white: 0.0, alpha: 0.5)
photoLabel.shadowOffset = CGSize(width: 0.0, height: 1.0)
photoLabel.font = UIFont.systemFontOfSize(17.0)
photoLabel.font = SKPhotoBrowserOptions.captionFont
photoLabel.text = photo?.caption
addSubview(photoLabel)
}

View File

@ -16,6 +16,6 @@ class SKIndicatorView: UIActivityIndicatorView {
override init(frame: CGRect) {
super.init(frame: frame)
center = CGPoint(x: frame.width / 2, y: frame.height / 2)
activityIndicatorViewStyle = .WhiteLarge
activityIndicatorViewStyle = SKPhotoBrowserOptions.backgroundColor.isEqual(UIColor.whiteColor()) ? .Gray : .WhiteLarge
}
}

View File

@ -0,0 +1,55 @@
//
// SKNavigationBar.swift
// SKPhotoBrowser
//
// Created by Григорий Уланов on 10.10.16.
// Copyright © 2016 suzuki_keishi. All rights reserved.
//
import UIKit
class SKNavigationBar: UINavigationBar {
var showFrame: CGRect!
var hideFrame: CGRect!
private static let toolBarHeight: CGFloat = 64.0
private weak var browser: SKPhotoBrowser?
convenience init(browser: SKPhotoBrowser) {
self.init(frame: CGRect.zero)
self.browser = browser
translucent = false
tintColor = UIColor.whiteColor()
barTintColor = UIColor.blackColor()
titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
let navigationItem = UINavigationItem()
pushNavigationItem(navigationItem, animated: false)
}
func updateNavigationBar(currentPageIndex: Int) {
guard let browser = browser else { return }
if browser.numberOfPhotos > 1 {
self.topItem?.title = "\(currentPageIndex + 1) \(SKPhotoBrowserOptions.navigationBarCounterSepatator) \(browser.numberOfPhotos)"
} else {
self.topItem?.title = nil
}
}
func setNewFrame(rect: CGRect) {
self.frame = rect
showFrame = rect
hideFrame = CGRect(x: rect.origin.x, y: rect.origin.y - 20, width: rect.size.width, height: rect.size.height)
}
func updateFrame(parentSize: CGSize) {
let newRect = CGRect(x: 0, y: 0, width: parentSize.width, height: SKNavigationBar.toolBarHeight)
setNewFrame(newRect)
}
}

View File

@ -28,8 +28,8 @@ class SKPagingScrollView: UIScrollView {
super.init(frame: frame)
pagingEnabled = true
showsHorizontalScrollIndicator = true
showsVerticalScrollIndicator = true
showsHorizontalScrollIndicator = SKPhotoBrowserOptions.displayHorizontalScrollIndicator
showsVerticalScrollIndicator = SKPhotoBrowserOptions.displayHorizontalScrollIndicator
}
convenience init(frame: CGRect, browser: SKPhotoBrowser) {

View File

@ -18,6 +18,8 @@ public class SKPhotoBrowser: UIViewController {
private var closeButton: SKCloseButton!
private var deleteButton: SKDeleteButton!
private var toolbar: SKToolbar!
private var navigationBar: SKNavigationBar!
// actions
private var activityViewController: UIActivityViewController!
@ -42,6 +44,10 @@ public class SKPhotoBrowser: UIViewController {
// timer
private var controlVisibilityTimer: NSTimer!
// blocks
public var willDismissPage: (() -> Void)?
public var didPresentPage: (() -> Void)?
// delegate
private let animator = SKAnimator()
@ -52,6 +58,10 @@ public class SKPhotoBrowser: UIViewController {
var numberOfPhotos: Int {
return photos.count
}
// statusbar initial state
private var statusbarHidden: Bool = UIApplication.sharedApplication().statusBarHidden
// MARK - Initializer
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
@ -108,11 +118,12 @@ public class SKPhotoBrowser: UIViewController {
configureAppearance()
configureCloseButton()
configureDeleteButton()
configureNavigationBar()
configureToolbar()
animator.willPresent(self)
didPresentPage?()
}
override public func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
@ -131,6 +142,7 @@ public class SKPhotoBrowser: UIViewController {
closeButton.updateFrame()
deleteButton.updateFrame()
navigationBar.updateFrame(view.bounds.size)
pagingScrollView.updateFrame(view.bounds, currentPageIndex: currentPageIndex)
toolbar.frame = frameForToolbarAtOrientation()
@ -180,6 +192,7 @@ public class SKPhotoBrowser: UIViewController {
isPerformingLayout = true
toolbar.updateToolbar(currentPageIndex)
navigationBar.updateNavigationBar(currentPageIndex)
// reset local cache
pagingScrollView.reload()
@ -194,6 +207,7 @@ public class SKPhotoBrowser: UIViewController {
}
public func prepareForClosePhotoBrowser() {
UIApplication.sharedApplication().setStatusBarHidden(statusbarHidden, withAnimation: .None)
cancelControlHiding()
applicationWindow.removeGestureRecognizer(panGesture)
NSObject.cancelPreviousPerformRequestsWithTarget(self)
@ -215,6 +229,7 @@ public class SKPhotoBrowser: UIViewController {
public func determineAndClose() {
delegate?.willDismissAtPageIndex?(currentPageIndex)
animator.willDismiss(self)
willDismissPage?()
}
}
@ -271,6 +286,7 @@ public extension SKPhotoBrowser {
}
isEndAnimationByToolBar = false
toolbar.updateToolbar(currentPageIndex)
navigationBar.updateNavigationBar(currentPageIndex)
let pageFrame = frameForPageAtIndex(index)
pagingScrollView.animate(pageFrame)
@ -440,7 +456,7 @@ internal extension SKPhotoBrowser {
? zoomingScrollView.center.y - viewHalfHeight
: -(zoomingScrollView.center.y - viewHalfHeight)) / viewHalfHeight
view.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(max(0.7, offset))
view.alpha = max(0.7, offset)
// gesture end
if sender.state == .Ended {
@ -464,7 +480,8 @@ internal extension SKPhotoBrowser {
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDuration(animationDuration)
UIView.setAnimationCurve(UIViewAnimationCurve.EaseIn)
view.backgroundColor = UIColor.blackColor()
view.backgroundColor = SKPhotoBrowserOptions.backgroundColor
view.alpha = 1
zoomingScrollView.center = CGPoint(x: finalX, y: finalY)
UIView.commitAnimations()
}
@ -521,12 +538,12 @@ internal extension SKPhotoBrowser {
// MARK: - Private Function
private extension SKPhotoBrowser {
func configureAppearance() {
view.backgroundColor = .blackColor()
view.backgroundColor = SKPhotoBrowserOptions.backgroundColor
view.clipsToBounds = true
view.opaque = false
backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: SKMesurement.screenWidth, height: SKMesurement.screenHeight))
backgroundView.backgroundColor = .blackColor()
backgroundView.backgroundColor = SKPhotoBrowserOptions.backgroundColor
backgroundView.alpha = 0.0
applicationWindow.addSubview(backgroundView)
@ -554,6 +571,13 @@ private extension SKPhotoBrowser {
deleteButton.hidden = !SKPhotoBrowserOptions.displayDeleteButton
view.addSubview(deleteButton)
}
func configureNavigationBar() {
navigationBar = SKNavigationBar(browser: self)
navigationBar.updateFrame(view.bounds.size)
navigationBar.hidden = !SKPhotoBrowserOptions.displayNavigationBar
view.addSubview(navigationBar)
}
func configureToolbar() {
toolbar = SKToolbar(frame: frameForToolbarAtOrientation(), browser: self)
@ -579,6 +603,10 @@ private extension SKPhotoBrowser {
self.deleteButton.alpha = alpha
self.deleteButton.frame = hidden ? self.deleteButton.hideFrame : self.deleteButton.showFrame
}
if SKPhotoBrowserOptions.displayNavigationBar {
self.navigationBar.alpha = alpha
self.navigationBar.frame = hidden ? self.navigationBar.hideFrame : self.navigationBar.showFrame
}
captionViews.forEach { $0.alpha = alpha }
},
completion: nil)
@ -602,6 +630,7 @@ private extension SKPhotoBrowser {
gotoPreviousPage()
}
toolbar.updateToolbar(currentPageIndex)
navigationBar.updateNavigationBar(currentPageIndex)
} else if photos.count == 1 {
dismissPhotoBrowser(animated: false)
@ -631,6 +660,7 @@ extension SKPhotoBrowser: UIScrollViewDelegate {
if currentPageIndex != previousCurrentPage {
delegate?.didShowPhotoAtIndex?(currentPageIndex)
toolbar.updateToolbar(currentPageIndex)
navigationBar.updateNavigationBar(currentPageIndex)
}
}

View File

@ -71,5 +71,6 @@ import Foundation
- Returns: the view to animate to
*/
optional func viewForPhoto(browser: SKPhotoBrowser, index: Int) -> UIView?
}

View File

@ -6,9 +6,11 @@
// Copyright © 2016 suzuki_keishi. All rights reserved.
//
import Foundation
import UIKit
public struct SKPhotoBrowserOptions {
public static var displayStatusbar: Bool = false
public static var displayAction: Bool = true
public static var shareExtraCaption: String? = nil
public static var actionButtonTitles: [String]?
@ -18,10 +20,27 @@ public struct SKPhotoBrowserOptions {
public static var displayBackAndForwardButton: Bool = true
public static var disableVerticalSwipe: Bool = false
public static var displayCloseButton = true
public static var displayDeleteButton = false
public static var displayCloseButton: Bool = true
public static var displayNavigationBar: Bool = true
public static var displayDeleteButton: Bool = false
public static var bounceAnimation = false
public static var enableZoomBlackArea = true
public static var enableSingleTapDismiss = false
}
public static var displayHorizontalScrollIndicator: Bool = true
public static var displayVerticalScrollIndicator: Bool = true
public static var bounceAnimation: Bool = false
public static var enableZoomBlackArea: Bool = true
public static var enableSingleTapDismiss: Bool = false
public static var backgroundColor = UIColor.blackColor()
public static var textAndIconColor = UIColor.whiteColor()
public static var toolbarTextShadowColor = UIColor.darkTextColor()
public static var navigationBarCounterSepatator: String = "из"
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

@ -109,16 +109,16 @@ private extension SKToolbar {
toolCounterLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 95, height: 40))
toolCounterLabel.textAlignment = .Center
toolCounterLabel.backgroundColor = .clearColor()
toolCounterLabel.font = UIFont(name: "Helvetica", size: 16.0)
toolCounterLabel.textColor = .whiteColor()
toolCounterLabel.shadowColor = .darkTextColor()
toolCounterLabel.font = SKPhotoBrowserOptions.toolbarFont
toolCounterLabel.textColor = SKPhotoBrowserOptions.textAndIconColor
toolCounterLabel.shadowColor = SKPhotoBrowserOptions.toolbarTextShadowColor
toolCounterLabel.shadowOffset = CGSize(width: 0.0, height: 1.0)
toolCounterButton = UIBarButtonItem(customView: toolCounterLabel)
}
func setupActionButton() {
toolActionButton = UIBarButtonItem(barButtonSystemItem: .Action, target: browser, action: #selector(SKPhotoBrowser.actionButtonPressed))
toolActionButton.tintColor = .whiteColor()
toolActionButton.tintColor = SKPhotoBrowserOptions.textAndIconColor
}
}
@ -128,13 +128,14 @@ class SKToolbarButton: UIButton {
func setup(imageName: String) {
backgroundColor = .clearColor()
tintColor = SKPhotoBrowserOptions.textAndIconColor
imageEdgeInsets = insets
translatesAutoresizingMaskIntoConstraints = true
autoresizingMask = [.FlexibleBottomMargin, .FlexibleLeftMargin, .FlexibleRightMargin, .FlexibleTopMargin]
contentMode = .Center
let image = UIImage(named: "SKPhotoBrowser.bundle/images/\(imageName)",
inBundle: bundle, compatibleWithTraitCollection: nil) ?? UIImage()
inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) ?? UIImage()
setImage(image, forState: .Normal)
}
}

View File

@ -48,7 +48,7 @@ public class SKZoomingScrollView: UIScrollView {
// tap
tapView = SKDetectingView(frame: bounds)
tapView.delegate = self
tapView.backgroundColor = UIColor.clearColor()
tapView.backgroundColor = .clearColor()
tapView.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
addSubview(tapView)
@ -182,10 +182,25 @@ 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();
// image
photoImageView.image = image
photoImageView.contentMode = photo.contentMode
photoImageView.backgroundColor = SKPhotoBrowserOptions.backgroundColor
var photoImageViewFrame = CGRect.zero
photoImageViewFrame.origin = CGPoint.zero
@ -323,4 +338,4 @@ private extension SKZoomingScrollView {
return CGRect(x: x, y: y, width: w, height: h)
}
}
}

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPhotoLibraryUsageDescription</key>
<string>for example, this app accesses the users photo library</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
@ -46,10 +48,10 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>