update example, readme.
This commit is contained in:
parent
934831b4bf
commit
d6ecf61405
47
README.md
47
README.md
|
|
@ -101,10 +101,6 @@ func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath i
|
|||
|
||||
#### Toolbar
|
||||
You can customize Toolbar via SKPhotoBrowserOptions.
|
||||
- displayCounterLabel (default is true)
|
||||
- displayBackAndForwardButton (default is true)
|
||||
- displayAction (default is true)
|
||||
|
||||
|
||||
```swift
|
||||
SKPhotoBrowserOptions.displayToolbar = false // all tool bar will be hidden
|
||||
|
|
@ -115,24 +111,29 @@ SKPhotoBrowserOptions.displayDeleteButton = true // delete button wil
|
|||
let browser = SKPhotoBrowser(originImage: originImage, photos: images, animatedFromView: cell)
|
||||
```
|
||||
|
||||
#### CustomButton Image
|
||||
Close button is able to change image and frame.
|
||||
``` swift
|
||||
browser.displayCustomCloseButton = true // custom close button will be enable
|
||||
browser.customCloseButtonImage = UIImage(named: "some.png")
|
||||
browser.customCloseButtonShowFrame = CGRect()
|
||||
browser.customCloseButtonHideFrame = CGRect()
|
||||
```
|
||||
Delete button is able to change image and frame.
|
||||
``` swift
|
||||
browser.displayCustomDeleteButton = true // custom delete button will be enable
|
||||
browser.customDeleteButtonImage = UIImage(named: "some.png")
|
||||
browser.customDeleteButtonShowFrame = CGRect()
|
||||
browser.customDeleteButtonHideFrame = CGRect()
|
||||
#### Custom Cache From Web URL
|
||||
You can use SKCacheable protocol if others are adaptable. (SKImageCacheable or SKRequestResponseCacheable)
|
||||
|
||||
```swift
|
||||
e.g. SDWebImage
|
||||
|
||||
// 1. create custon cache. implement function for protocol
|
||||
class CustomImageCache: SKImageCacheable { var cache: SDImageCache }
|
||||
|
||||
// 2. replace SKCache instance with custom cache
|
||||
SKCache.sharedCache.imageCache = CustomImageCache()
|
||||
```
|
||||
|
||||
#### Delete
|
||||
You can delete your photo for your own hanlding.
|
||||
#### CustomButton Image
|
||||
Close, Delete buttons are able to change image and frame.
|
||||
``` swift
|
||||
browser.browser.updateCloseButton(UIImage())
|
||||
browser.browser.updateUpdateButton(UIImage())
|
||||
```
|
||||
|
||||
#### Delete Photo
|
||||
You can delete your photo for your own handling. detect button tap from `removePhoto` delegate function.
|
||||
|
||||
|
||||
#### Photo Captions
|
||||
Photo captions can be displayed simply bottom of PhotoBrowser. by setting the `caption` property on specific photos:
|
||||
|
|
@ -184,9 +185,9 @@ func didDismissAtPageIndex(index: Int) {
|
|||
- single tap handling, dismiss/noaction
|
||||
- bounce animation when appearing/dismissing
|
||||
``` swift
|
||||
enableZoomBlackArea = true // default true
|
||||
enableSingleTapDismiss = true // default false
|
||||
bounceAnimation = true // default false
|
||||
SKPhotoBrowserOptions.enableZoomBlackArea = true // default true
|
||||
SKPhotoBrowserOptions.enableSingleTapDismiss = true // default false
|
||||
SKPhotoBrowserOptions.bounceAnimation = true // default false
|
||||
```
|
||||
|
||||
## Photos from
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'SDWebImage', '~>3.8'
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
PODS:
|
||||
- SDWebImage (3.8.1):
|
||||
- SDWebImage/Core (= 3.8.1)
|
||||
- SDWebImage/Core (3.8.1)
|
||||
|
||||
DEPENDENCIES:
|
||||
- SDWebImage (~> 3.8)
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
SDWebImage: 35f9627a3e44b4f292a8a8ce6a531fa488239b91
|
||||
|
||||
COCOAPODS: 0.39.0
|
||||
File diff suppressed because it is too large
Load Diff
10
SKPhotoBrowserExample/SKPhotoBrowserExample.xcworkspace/contents.xcworkspacedata
generated
Normal file
10
SKPhotoBrowserExample/SKPhotoBrowserExample.xcworkspace/contents.xcworkspacedata
generated
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:SKPhotoBrowserExample.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="qgG-zu-Htx">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="qgG-zu-Htx">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
</dependencies>
|
||||
|
|
@ -88,14 +88,26 @@
|
|||
<action selector="pushButton:" destination="wTD-ba-cWw" eventType="touchUpInside" id="xIc-2O-Gmb"/>
|
||||
</connections>
|
||||
</button>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="yxe-Wd-8iE">
|
||||
<rect key="frame" x="180" y="78" width="240" height="128"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="128" id="a4K-nx-MJW"/>
|
||||
<constraint firstAttribute="width" constant="240" id="tzG-IV-N9z"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="ZK0-HE-9Bs" firstAttribute="top" secondItem="yxe-Wd-8iE" secondAttribute="bottom" constant="50" id="8Aq-op-KMh"/>
|
||||
<constraint firstItem="ZK0-HE-9Bs" firstAttribute="centerY" secondItem="pNX-nL-SLw" secondAttribute="centerY" id="9jd-Un-cAK"/>
|
||||
<constraint firstItem="ZK0-HE-9Bs" firstAttribute="centerX" secondItem="pNX-nL-SLw" secondAttribute="centerX" id="h6U-H1-RV4"/>
|
||||
<constraint firstItem="yxe-Wd-8iE" firstAttribute="centerX" secondItem="pNX-nL-SLw" secondAttribute="centerX" id="xA1-uS-dJw"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<tabBarItem key="tabBarItem" title="FromWeb" id="2lE-np-9H3"/>
|
||||
<connections>
|
||||
<outlet property="imageView" destination="yxe-Wd-8iE" id="aMH-Df-3r0"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="jdP-ty-Ygs" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
|
|
|
|||
|
|
@ -8,12 +8,19 @@
|
|||
|
||||
import UIKit
|
||||
import SKPhotoBrowser
|
||||
import SDWebImage
|
||||
|
||||
class FromWebViewController: UIViewController, SKPhotoBrowserDelegate {
|
||||
@IBOutlet weak var imageView: UIImageView!
|
||||
var images = [SKPhotoProtocol]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
SKCache.sharedCache.imageCache = CustomImageCache()
|
||||
imageView.sd_setImageWithURL(NSURL(string: "https://placehold.jp/1500x1500.png")) {
|
||||
SKCache.sharedCache.setImage($0.0, forKey: $0.3.absoluteString)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func pushButton(sender: AnyObject) {
|
||||
|
|
@ -35,6 +42,7 @@ extension FromWebViewController {
|
|||
}
|
||||
|
||||
func removePhoto(browser: SKPhotoBrowser, index: Int, reload: (() -> Void)) {
|
||||
SKCache.sharedCache.removeImageForKey("somekey")
|
||||
reload()
|
||||
}
|
||||
}
|
||||
|
|
@ -52,3 +60,24 @@ private extension FromWebViewController {
|
|||
}
|
||||
}
|
||||
|
||||
class CustomImageCache: SKImageCacheable {
|
||||
var cache: SDImageCache
|
||||
|
||||
init() {
|
||||
let cache = SDImageCache(namespace: "com.suzuki.custom.cache")
|
||||
self.cache = cache
|
||||
}
|
||||
|
||||
func imageForKey(key: String) -> UIImage? {
|
||||
guard let image = cache.imageFromDiskCacheForKey(key) else { return nil }
|
||||
|
||||
return image
|
||||
}
|
||||
|
||||
func setImage(image: UIImage, forKey key: String) {
|
||||
cache.storeImage(image, forKey: key)
|
||||
}
|
||||
|
||||
func removeImageForKey(key: String) {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue