├── .gitignore ├── GSImageViewerController.podspec ├── GSImageViewerController └── GSImageViewerController.swift ├── GSImageViewerControllerExample ├── GSImageViewerControllerExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── GSImageViewerControllerExample │ ├── 0.jpg │ ├── 1.jpg │ ├── 2.jpg │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── LICENSE ├── Package.swift ├── README.md └── demo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /GSImageViewerController.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "GSImageViewerController" 3 | s.version = "1.6.3" 4 | s.summary = "A image viewer controller with zoom transition, in Swift." 5 | s.homepage = "https://github.com/wxxsw/GSImageViewerController" 6 | 7 | s.license = 'MIT' 8 | s.author = { "Gesen" => "i@gesen.me" } 9 | s.source = { :git => "https://github.com/wxxsw/GSImageViewerController.git", :tag => s.version.to_s } 10 | 11 | s.platform = :ios, '9.0' 12 | s.requires_arc = true 13 | 14 | s.source_files = 'GSImageViewerController' 15 | 16 | s.swift_version = "4.2" 17 | s.swift_versions = ['4.0', '4.2', '5.0'] 18 | end 19 | -------------------------------------------------------------------------------- /GSImageViewerController/GSImageViewerController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GSImageViewerController.swift 3 | // GSImageViewerControllerExample 4 | // 5 | // Created by Gesen on 15/12/22. 6 | // Copyright © 2015年 Gesen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public struct GSImageInfo { 12 | 13 | public enum ImageMode : Int { 14 | case aspectFit = 1 15 | case aspectFill = 2 16 | } 17 | 18 | public let image : UIImage 19 | public let imageMode : ImageMode 20 | public var imageHD : URL? 21 | 22 | public var contentMode : UIView.ContentMode { 23 | return UIView.ContentMode(rawValue: imageMode.rawValue)! 24 | } 25 | 26 | public init(image: UIImage, imageMode: ImageMode) { 27 | self.image = image 28 | self.imageMode = imageMode 29 | } 30 | 31 | public init(image: UIImage, imageMode: ImageMode, imageHD: URL?) { 32 | self.init(image: image, imageMode: imageMode) 33 | self.imageHD = imageHD 34 | } 35 | 36 | func calculate(rect: CGRect, origin: CGPoint? = nil, imageMode: ImageMode? = nil) -> CGRect { 37 | switch imageMode ?? self.imageMode { 38 | 39 | case .aspectFit: 40 | return rect 41 | 42 | case .aspectFill: 43 | let r = max(rect.size.width / image.size.width, rect.size.height / image.size.height) 44 | let w = image.size.width * r 45 | let h = image.size.height * r 46 | 47 | return CGRect( 48 | x : origin?.x ?? rect.origin.x - (w - rect.width) / 2, 49 | y : origin?.y ?? rect.origin.y - (h - rect.height) / 2, 50 | width : w, 51 | height : h 52 | ) 53 | } 54 | } 55 | 56 | func calculateMaximumZoomScale(_ size: CGSize) -> CGFloat { 57 | return max(2, max( 58 | image.size.width / size.width, 59 | image.size.height / size.height 60 | )) 61 | } 62 | 63 | } 64 | 65 | open class GSTransitionInfo { 66 | 67 | public enum Animation { 68 | case linear 69 | case spring(damping: CGFloat, initialVelocity: CGFloat) 70 | } 71 | 72 | open var duration: TimeInterval = 0.35 73 | open var canSwipe: Bool = true 74 | open var animation: Animation = .linear 75 | 76 | public init(fromView: UIView) { 77 | self.fromView = fromView 78 | } 79 | 80 | public init(fromRect: CGRect) { 81 | self.convertedRect = fromRect 82 | } 83 | 84 | weak var fromView: UIView? 85 | 86 | fileprivate var fromRect: CGRect! 87 | fileprivate var convertedRect: CGRect! 88 | 89 | } 90 | 91 | open class GSImageViewerController: UIViewController { 92 | 93 | public let imageView = UIImageView() 94 | public let scrollView = UIScrollView() 95 | 96 | public let imageInfo: GSImageInfo 97 | 98 | open var transitionInfo: GSTransitionInfo? 99 | 100 | open var dismissCompletion: (() -> Void)? 101 | 102 | open var backgroundColor: UIColor = .black { 103 | didSet { 104 | view.backgroundColor = backgroundColor 105 | } 106 | } 107 | 108 | open lazy var session: URLSession = { 109 | let configuration = URLSessionConfiguration.ephemeral 110 | return URLSession(configuration: configuration, delegate: nil, delegateQueue: OperationQueue.main) 111 | }() 112 | 113 | // MARK: Initialization 114 | 115 | public init(imageInfo: GSImageInfo) { 116 | self.imageInfo = imageInfo 117 | super.init(nibName: nil, bundle: nil) 118 | } 119 | 120 | public convenience init(imageInfo: GSImageInfo, transitionInfo: GSTransitionInfo) { 121 | self.init(imageInfo: imageInfo) 122 | self.transitionInfo = transitionInfo 123 | 124 | if let fromView = transitionInfo.fromView, let referenceView = fromView.superview { 125 | transitionInfo.fromRect = referenceView.convert(fromView.frame, to: nil) 126 | 127 | if fromView.contentMode != imageInfo.contentMode { 128 | transitionInfo.convertedRect = imageInfo.calculate( 129 | rect: transitionInfo.fromRect!, 130 | imageMode: GSImageInfo.ImageMode(rawValue: fromView.contentMode.rawValue) 131 | ) 132 | } else { 133 | transitionInfo.convertedRect = transitionInfo.fromRect 134 | } 135 | } 136 | 137 | if transitionInfo.convertedRect != nil { 138 | self.transitioningDelegate = self 139 | self.modalPresentationStyle = .overFullScreen 140 | } 141 | } 142 | 143 | public convenience init(image: UIImage, imageMode: UIView.ContentMode, imageHD: URL?, fromView: UIView?) { 144 | let imageInfo = GSImageInfo(image: image, imageMode: GSImageInfo.ImageMode(rawValue: imageMode.rawValue)!, imageHD: imageHD) 145 | 146 | if let fromView = fromView { 147 | self.init(imageInfo: imageInfo, transitionInfo: GSTransitionInfo(fromView: fromView)) 148 | } else { 149 | self.init(imageInfo: imageInfo) 150 | } 151 | } 152 | 153 | public required init?(coder aDecoder: NSCoder) { 154 | fatalError("init(coder:) has not been implemented") 155 | } 156 | 157 | // MARK: Override 158 | 159 | override open func viewDidLoad() { 160 | super.viewDidLoad() 161 | 162 | setupView() 163 | setupScrollView() 164 | setupImageView() 165 | setupGesture() 166 | setupImageHD() 167 | 168 | edgesForExtendedLayout = UIRectEdge() 169 | automaticallyAdjustsScrollViewInsets = false 170 | } 171 | 172 | override open func viewWillLayoutSubviews() { 173 | super.viewWillLayoutSubviews() 174 | 175 | imageView.frame = imageInfo.calculate(rect: view.bounds, origin: .zero) 176 | 177 | scrollView.frame = view.bounds 178 | scrollView.contentSize = imageView.bounds.size 179 | scrollView.maximumZoomScale = imageInfo.calculateMaximumZoomScale(scrollView.bounds.size) 180 | } 181 | 182 | // MARK: Setups 183 | 184 | fileprivate func setupView() { 185 | view.backgroundColor = backgroundColor 186 | } 187 | 188 | fileprivate func setupScrollView() { 189 | scrollView.delegate = self 190 | scrollView.minimumZoomScale = 1.0 191 | scrollView.showsHorizontalScrollIndicator = false 192 | scrollView.showsVerticalScrollIndicator = false 193 | view.addSubview(scrollView) 194 | } 195 | 196 | fileprivate func setupImageView() { 197 | imageView.image = imageInfo.image 198 | imageView.contentMode = .scaleAspectFit 199 | scrollView.addSubview(imageView) 200 | } 201 | 202 | fileprivate func setupGesture() { 203 | let single = UITapGestureRecognizer(target: self, action: #selector(singleTap)) 204 | let double = UITapGestureRecognizer(target: self, action: #selector(doubleTap(_:))) 205 | double.numberOfTapsRequired = 2 206 | single.require(toFail: double) 207 | scrollView.addGestureRecognizer(single) 208 | scrollView.addGestureRecognizer(double) 209 | 210 | if transitionInfo?.canSwipe == true { 211 | let pan = UIPanGestureRecognizer(target: self, action: #selector(pan(_:))) 212 | pan.delegate = self 213 | scrollView.addGestureRecognizer(pan) 214 | } 215 | } 216 | 217 | fileprivate func setupImageHD() { 218 | guard let imageHD = imageInfo.imageHD else { return } 219 | 220 | let request = URLRequest(url: imageHD, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: 15) 221 | let task = session.dataTask(with: request, completionHandler: { (data, response, error) -> Void in 222 | guard let data = data else { return } 223 | guard let image = UIImage(data: data) else { return } 224 | self.imageView.image = image 225 | self.view.layoutIfNeeded() 226 | }) 227 | task.resume() 228 | } 229 | 230 | // MARK: Gesture 231 | 232 | @objc fileprivate func singleTap() { 233 | if navigationController == nil || (presentingViewController != nil && navigationController!.viewControllers.count <= 1) { 234 | dismiss(animated: true, completion: dismissCompletion) 235 | } 236 | } 237 | 238 | @objc fileprivate func doubleTap(_ gesture: UITapGestureRecognizer) { 239 | let point = gesture.location(in: scrollView) 240 | 241 | if scrollView.zoomScale == 1.0 { 242 | scrollView.zoom(to: CGRect(x: point.x-40, y: point.y-40, width: 80, height: 80), animated: true) 243 | } else { 244 | scrollView.setZoomScale(1.0, animated: true) 245 | } 246 | } 247 | 248 | fileprivate var panViewOrigin : CGPoint? 249 | fileprivate var panViewAlpha : CGFloat = 1 250 | 251 | @objc fileprivate func pan(_ gesture: UIPanGestureRecognizer) { 252 | 253 | func getProgress() -> CGFloat { 254 | let origin = panViewOrigin! 255 | let changeX = abs(scrollView.center.x - origin.x) 256 | let changeY = abs(scrollView.center.y - origin.y) 257 | let progressX = changeX / view.bounds.width 258 | let progressY = changeY / view.bounds.height 259 | return max(progressX, progressY) 260 | } 261 | 262 | func getChanged() -> CGPoint { 263 | let origin = scrollView.center 264 | let change = gesture.translation(in: view) 265 | return CGPoint(x: origin.x + change.x, y: origin.y + change.y) 266 | } 267 | 268 | func getVelocity() -> CGFloat { 269 | let vel = gesture.velocity(in: scrollView) 270 | return sqrt(vel.x*vel.x + vel.y*vel.y) 271 | } 272 | 273 | switch gesture.state { 274 | 275 | case .began: 276 | 277 | panViewOrigin = scrollView.center 278 | 279 | case .changed: 280 | 281 | scrollView.center = getChanged() 282 | panViewAlpha = 1 - getProgress() 283 | view.backgroundColor = backgroundColor.withAlphaComponent(panViewAlpha) 284 | gesture.setTranslation(CGPoint.zero, in: nil) 285 | 286 | case .ended: 287 | 288 | if getProgress() > 0.25 || getVelocity() > 1000 { 289 | dismiss(animated: true, completion: dismissCompletion) 290 | } else { 291 | fallthrough 292 | } 293 | 294 | default: 295 | 296 | UIView.animate(withDuration: 0.3, 297 | animations: { 298 | self.scrollView.center = self.panViewOrigin! 299 | self.view.backgroundColor = self.backgroundColor 300 | }, 301 | completion: { _ in 302 | self.panViewOrigin = nil 303 | self.panViewAlpha = 1.0 304 | } 305 | ) 306 | 307 | } 308 | } 309 | 310 | } 311 | 312 | extension GSImageViewerController: UIScrollViewDelegate { 313 | 314 | public func viewForZooming(in scrollView: UIScrollView) -> UIView? { 315 | return imageView 316 | } 317 | 318 | public func scrollViewDidZoom(_ scrollView: UIScrollView) { 319 | imageView.frame = imageInfo.calculate(rect: CGRect(origin: .zero, size: scrollView.contentSize), origin: .zero) 320 | } 321 | 322 | } 323 | 324 | extension GSImageViewerController: UIViewControllerTransitioningDelegate { 325 | 326 | public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { 327 | return GSImageViewerTransition(imageInfo: imageInfo, transitionInfo: transitionInfo!, transitionMode: .present) 328 | } 329 | 330 | public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { 331 | return GSImageViewerTransition(imageInfo: imageInfo, transitionInfo: transitionInfo!, transitionMode: .dismiss) 332 | } 333 | 334 | } 335 | 336 | class GSImageViewerTransition: NSObject, UIViewControllerAnimatedTransitioning { 337 | 338 | let imageInfo : GSImageInfo 339 | let transitionInfo : GSTransitionInfo 340 | var transitionMode : TransitionMode 341 | 342 | enum TransitionMode { 343 | case present 344 | case dismiss 345 | } 346 | 347 | init(imageInfo: GSImageInfo, transitionInfo: GSTransitionInfo, transitionMode: TransitionMode) { 348 | self.imageInfo = imageInfo 349 | self.transitionInfo = transitionInfo 350 | self.transitionMode = transitionMode 351 | super.init() 352 | } 353 | 354 | func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { 355 | return transitionInfo.duration 356 | } 357 | 358 | func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { 359 | let containerView = transitionContext.containerView 360 | 361 | let tempBackground = UIView() 362 | tempBackground.backgroundColor = UIColor.black 363 | 364 | let tempMask = UIView() 365 | tempMask.backgroundColor = .black 366 | tempMask.layer.cornerRadius = transitionInfo.fromView?.layer.cornerRadius ?? 0 367 | tempMask.layer.masksToBounds = transitionInfo.fromView?.layer.masksToBounds ?? false 368 | 369 | let tempImage = UIImageView(image: imageInfo.image) 370 | tempImage.contentMode = imageInfo.contentMode 371 | tempImage.mask = tempMask 372 | 373 | containerView.addSubview(tempBackground) 374 | containerView.addSubview(tempImage) 375 | 376 | if transitionMode == .present { 377 | let imageViewer = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.to) as! GSImageViewerController 378 | imageViewer.view.layoutIfNeeded() 379 | 380 | tempBackground.alpha = 0 381 | tempBackground.frame = imageViewer.view.bounds 382 | tempImage.frame = transitionInfo.convertedRect 383 | tempMask.frame = tempImage.convert(transitionInfo.fromRect, from: nil) 384 | 385 | transitionInfo.fromView?.alpha = 0 386 | 387 | animationBlock(for: transitionInfo, { 388 | tempBackground.alpha = 1 389 | tempImage.frame = imageViewer.imageView.frame 390 | tempMask.frame = tempImage.bounds 391 | }, { 392 | tempBackground.removeFromSuperview() 393 | tempImage.removeFromSuperview() 394 | containerView.addSubview(imageViewer.view) 395 | transitionContext.completeTransition(true) 396 | }) 397 | } 398 | 399 | else if transitionMode == .dismiss { 400 | let imageViewer = transitionContext.viewController(forKey: UITransitionContextViewControllerKey.from) as! GSImageViewerController 401 | imageViewer.view.removeFromSuperview() 402 | 403 | tempBackground.alpha = imageViewer.panViewAlpha 404 | tempBackground.frame = imageViewer.view.bounds 405 | 406 | if imageViewer.scrollView.zoomScale == 1 && imageInfo.imageMode == .aspectFit { 407 | tempImage.frame = imageViewer.scrollView.frame 408 | } else { 409 | tempImage.frame = CGRect(x: imageViewer.scrollView.contentOffset.x * -1, y: imageViewer.scrollView.contentOffset.y * -1, width: imageViewer.scrollView.contentSize.width, height: imageViewer.scrollView.contentSize.height) 410 | } 411 | 412 | tempMask.frame = tempImage.bounds 413 | 414 | self.animationBlock(for: transitionInfo, { [weak self] in 415 | guard let strongSelf = self else { 416 | return 417 | } 418 | tempBackground.alpha = 0 419 | tempImage.frame = strongSelf.transitionInfo.convertedRect 420 | tempMask.frame = tempImage.convert(strongSelf.transitionInfo.fromRect, from: nil) 421 | }, { [weak self] in 422 | guard let strongSelf = self else { 423 | return 424 | } 425 | tempBackground.removeFromSuperview() 426 | tempImage.removeFromSuperview() 427 | imageViewer.view.removeFromSuperview() 428 | strongSelf.transitionInfo.fromView?.alpha = 1 429 | transitionContext.completeTransition(true) 430 | }) 431 | } 432 | } 433 | 434 | private func animationBlock(for transition: GSTransitionInfo, 435 | _ animations: @escaping () -> Void, 436 | _ completionBlock: (() -> Void)?) { 437 | 438 | switch transition.animation { 439 | case .linear: 440 | UIView.animate(withDuration: transitionInfo.duration, animations: { 441 | animations() 442 | }, completion: { _ in 443 | completionBlock?() 444 | }) 445 | case let .spring(damping, velocity): 446 | UIView.animate(withDuration: transitionInfo.duration, delay: 0.0, usingSpringWithDamping: damping, initialSpringVelocity: velocity) { 447 | animations() 448 | } completion: { _ in 449 | completionBlock?() 450 | } 451 | } 452 | } 453 | } 454 | 455 | extension GSImageViewerController: UIGestureRecognizerDelegate { 456 | 457 | public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 458 | if let pan = gestureRecognizer as? UIPanGestureRecognizer { 459 | if scrollView.zoomScale != 1.0 { 460 | return false 461 | } 462 | if imageInfo.imageMode == .aspectFill && (scrollView.contentOffset.x > 0 || pan.translation(in: view).x <= 0) { 463 | return false 464 | } 465 | } 466 | return true 467 | } 468 | 469 | } 470 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 187BB8CA1C29089A00F5B7E5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 187BB8C91C29089A00F5B7E5 /* AppDelegate.swift */; }; 11 | 187BB8CC1C29089A00F5B7E5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 187BB8CB1C29089A00F5B7E5 /* ViewController.swift */; }; 12 | 187BB8CF1C29089A00F5B7E5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 187BB8CD1C29089A00F5B7E5 /* Main.storyboard */; }; 13 | 187BB8D11C29089A00F5B7E5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 187BB8D01C29089A00F5B7E5 /* Assets.xcassets */; }; 14 | 187BB8D41C29089A00F5B7E5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 187BB8D21C29089A00F5B7E5 /* LaunchScreen.storyboard */; }; 15 | 187BB8DD1C2908D800F5B7E5 /* GSImageViewerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 187BB8DC1C2908D800F5B7E5 /* GSImageViewerController.swift */; }; 16 | 18987B951C62001100DF1998 /* 0.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18987B921C62001100DF1998 /* 0.jpg */; }; 17 | 18987B961C62001100DF1998 /* 1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18987B931C62001100DF1998 /* 1.jpg */; }; 18 | 18987B971C62001100DF1998 /* 2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 18987B941C62001100DF1998 /* 2.jpg */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 187BB8C61C29089A00F5B7E5 /* GSImageViewerControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GSImageViewerControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 187BB8C91C29089A00F5B7E5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | 187BB8CB1C29089A00F5B7E5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | 187BB8CE1C29089A00F5B7E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 187BB8D01C29089A00F5B7E5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 187BB8D31C29089A00F5B7E5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 187BB8D51C29089A00F5B7E5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | 187BB8DC1C2908D800F5B7E5 /* GSImageViewerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GSImageViewerController.swift; sourceTree = ""; }; 30 | 18987B921C62001100DF1998 /* 0.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 0.jpg; sourceTree = ""; }; 31 | 18987B931C62001100DF1998 /* 1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 1.jpg; sourceTree = ""; }; 32 | 18987B941C62001100DF1998 /* 2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = 2.jpg; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | 187BB8C31C29089A00F5B7E5 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 187BB8BD1C29089A00F5B7E5 = { 47 | isa = PBXGroup; 48 | children = ( 49 | 187BB8DB1C2908BF00F5B7E5 /* GSImageViewerController */, 50 | 187BB8C81C29089A00F5B7E5 /* GSImageViewerControllerExample */, 51 | 187BB8C71C29089A00F5B7E5 /* Products */, 52 | ); 53 | sourceTree = ""; 54 | }; 55 | 187BB8C71C29089A00F5B7E5 /* Products */ = { 56 | isa = PBXGroup; 57 | children = ( 58 | 187BB8C61C29089A00F5B7E5 /* GSImageViewerControllerExample.app */, 59 | ); 60 | name = Products; 61 | sourceTree = ""; 62 | }; 63 | 187BB8C81C29089A00F5B7E5 /* GSImageViewerControllerExample */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | 187BB8C91C29089A00F5B7E5 /* AppDelegate.swift */, 67 | 187BB8CB1C29089A00F5B7E5 /* ViewController.swift */, 68 | 187BB8CD1C29089A00F5B7E5 /* Main.storyboard */, 69 | 18987B921C62001100DF1998 /* 0.jpg */, 70 | 18987B931C62001100DF1998 /* 1.jpg */, 71 | 18987B941C62001100DF1998 /* 2.jpg */, 72 | 187BB8D01C29089A00F5B7E5 /* Assets.xcassets */, 73 | 187BB8D21C29089A00F5B7E5 /* LaunchScreen.storyboard */, 74 | 187BB8D51C29089A00F5B7E5 /* Info.plist */, 75 | ); 76 | path = GSImageViewerControllerExample; 77 | sourceTree = ""; 78 | }; 79 | 187BB8DB1C2908BF00F5B7E5 /* GSImageViewerController */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 187BB8DC1C2908D800F5B7E5 /* GSImageViewerController.swift */, 83 | ); 84 | name = GSImageViewerController; 85 | path = ../GSImageViewerController; 86 | sourceTree = ""; 87 | }; 88 | /* End PBXGroup section */ 89 | 90 | /* Begin PBXNativeTarget section */ 91 | 187BB8C51C29089A00F5B7E5 /* GSImageViewerControllerExample */ = { 92 | isa = PBXNativeTarget; 93 | buildConfigurationList = 187BB8D81C29089A00F5B7E5 /* Build configuration list for PBXNativeTarget "GSImageViewerControllerExample" */; 94 | buildPhases = ( 95 | 187BB8C21C29089A00F5B7E5 /* Sources */, 96 | 187BB8C31C29089A00F5B7E5 /* Frameworks */, 97 | 187BB8C41C29089A00F5B7E5 /* Resources */, 98 | ); 99 | buildRules = ( 100 | ); 101 | dependencies = ( 102 | ); 103 | name = GSImageViewerControllerExample; 104 | productName = GSImageViewerControllerExample; 105 | productReference = 187BB8C61C29089A00F5B7E5 /* GSImageViewerControllerExample.app */; 106 | productType = "com.apple.product-type.application"; 107 | }; 108 | /* End PBXNativeTarget section */ 109 | 110 | /* Begin PBXProject section */ 111 | 187BB8BE1C29089A00F5B7E5 /* Project object */ = { 112 | isa = PBXProject; 113 | attributes = { 114 | LastSwiftUpdateCheck = 0710; 115 | LastUpgradeCheck = 1020; 116 | ORGANIZATIONNAME = Gesen; 117 | TargetAttributes = { 118 | 187BB8C51C29089A00F5B7E5 = { 119 | CreatedOnToolsVersion = 7.1; 120 | DevelopmentTeam = DBTR8NXFB4; 121 | LastSwiftMigration = 1000; 122 | }; 123 | }; 124 | }; 125 | buildConfigurationList = 187BB8C11C29089A00F5B7E5 /* Build configuration list for PBXProject "GSImageViewerControllerExample" */; 126 | compatibilityVersion = "Xcode 3.2"; 127 | developmentRegion = en; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | en, 131 | Base, 132 | ); 133 | mainGroup = 187BB8BD1C29089A00F5B7E5; 134 | productRefGroup = 187BB8C71C29089A00F5B7E5 /* Products */; 135 | projectDirPath = ""; 136 | projectRoot = ""; 137 | targets = ( 138 | 187BB8C51C29089A00F5B7E5 /* GSImageViewerControllerExample */, 139 | ); 140 | }; 141 | /* End PBXProject section */ 142 | 143 | /* Begin PBXResourcesBuildPhase section */ 144 | 187BB8C41C29089A00F5B7E5 /* Resources */ = { 145 | isa = PBXResourcesBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | 187BB8D41C29089A00F5B7E5 /* LaunchScreen.storyboard in Resources */, 149 | 187BB8D11C29089A00F5B7E5 /* Assets.xcassets in Resources */, 150 | 18987B971C62001100DF1998 /* 2.jpg in Resources */, 151 | 18987B951C62001100DF1998 /* 0.jpg in Resources */, 152 | 18987B961C62001100DF1998 /* 1.jpg in Resources */, 153 | 187BB8CF1C29089A00F5B7E5 /* Main.storyboard in Resources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXResourcesBuildPhase section */ 158 | 159 | /* Begin PBXSourcesBuildPhase section */ 160 | 187BB8C21C29089A00F5B7E5 /* Sources */ = { 161 | isa = PBXSourcesBuildPhase; 162 | buildActionMask = 2147483647; 163 | files = ( 164 | 187BB8CC1C29089A00F5B7E5 /* ViewController.swift in Sources */, 165 | 187BB8DD1C2908D800F5B7E5 /* GSImageViewerController.swift in Sources */, 166 | 187BB8CA1C29089A00F5B7E5 /* AppDelegate.swift in Sources */, 167 | ); 168 | runOnlyForDeploymentPostprocessing = 0; 169 | }; 170 | /* End PBXSourcesBuildPhase section */ 171 | 172 | /* Begin PBXVariantGroup section */ 173 | 187BB8CD1C29089A00F5B7E5 /* Main.storyboard */ = { 174 | isa = PBXVariantGroup; 175 | children = ( 176 | 187BB8CE1C29089A00F5B7E5 /* Base */, 177 | ); 178 | name = Main.storyboard; 179 | sourceTree = ""; 180 | }; 181 | 187BB8D21C29089A00F5B7E5 /* LaunchScreen.storyboard */ = { 182 | isa = PBXVariantGroup; 183 | children = ( 184 | 187BB8D31C29089A00F5B7E5 /* Base */, 185 | ); 186 | name = LaunchScreen.storyboard; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXVariantGroup section */ 190 | 191 | /* Begin XCBuildConfiguration section */ 192 | 187BB8D61C29089A00F5B7E5 /* Debug */ = { 193 | isa = XCBuildConfiguration; 194 | buildSettings = { 195 | ALWAYS_SEARCH_USER_PATHS = NO; 196 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 197 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 198 | CLANG_CXX_LIBRARY = "libc++"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 202 | CLANG_WARN_BOOL_CONVERSION = YES; 203 | CLANG_WARN_COMMA = YES; 204 | CLANG_WARN_CONSTANT_CONVERSION = YES; 205 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 206 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 207 | CLANG_WARN_EMPTY_BODY = YES; 208 | CLANG_WARN_ENUM_CONVERSION = YES; 209 | CLANG_WARN_INFINITE_RECURSION = YES; 210 | CLANG_WARN_INT_CONVERSION = YES; 211 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 212 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 213 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 214 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 215 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 216 | CLANG_WARN_STRICT_PROTOTYPES = YES; 217 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 218 | CLANG_WARN_UNREACHABLE_CODE = YES; 219 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 220 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 221 | COPY_PHASE_STRIP = NO; 222 | DEBUG_INFORMATION_FORMAT = dwarf; 223 | ENABLE_STRICT_OBJC_MSGSEND = YES; 224 | ENABLE_TESTABILITY = YES; 225 | GCC_C_LANGUAGE_STANDARD = gnu99; 226 | GCC_DYNAMIC_NO_PIC = NO; 227 | GCC_NO_COMMON_BLOCKS = YES; 228 | GCC_OPTIMIZATION_LEVEL = 0; 229 | GCC_PREPROCESSOR_DEFINITIONS = ( 230 | "DEBUG=1", 231 | "$(inherited)", 232 | ); 233 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 234 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 235 | GCC_WARN_UNDECLARED_SELECTOR = YES; 236 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 237 | GCC_WARN_UNUSED_FUNCTION = YES; 238 | GCC_WARN_UNUSED_VARIABLE = YES; 239 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 240 | MTL_ENABLE_DEBUG_INFO = YES; 241 | ONLY_ACTIVE_ARCH = YES; 242 | SDKROOT = iphoneos; 243 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 244 | }; 245 | name = Debug; 246 | }; 247 | 187BB8D71C29089A00F5B7E5 /* Release */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ALWAYS_SEARCH_USER_PATHS = NO; 251 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 252 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 253 | CLANG_CXX_LIBRARY = "libc++"; 254 | CLANG_ENABLE_MODULES = YES; 255 | CLANG_ENABLE_OBJC_ARC = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_EMPTY_BODY = YES; 263 | CLANG_WARN_ENUM_CONVERSION = YES; 264 | CLANG_WARN_INFINITE_RECURSION = YES; 265 | CLANG_WARN_INT_CONVERSION = YES; 266 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 267 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 268 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 270 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 271 | CLANG_WARN_STRICT_PROTOTYPES = YES; 272 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 273 | CLANG_WARN_UNREACHABLE_CODE = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 276 | COPY_PHASE_STRIP = NO; 277 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 278 | ENABLE_NS_ASSERTIONS = NO; 279 | ENABLE_STRICT_OBJC_MSGSEND = YES; 280 | GCC_C_LANGUAGE_STANDARD = gnu99; 281 | GCC_NO_COMMON_BLOCKS = YES; 282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 284 | GCC_WARN_UNDECLARED_SELECTOR = YES; 285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 286 | GCC_WARN_UNUSED_FUNCTION = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 289 | MTL_ENABLE_DEBUG_INFO = NO; 290 | SDKROOT = iphoneos; 291 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 292 | VALIDATE_PRODUCT = YES; 293 | }; 294 | name = Release; 295 | }; 296 | 187BB8D91C29089A00F5B7E5 /* Debug */ = { 297 | isa = XCBuildConfiguration; 298 | buildSettings = { 299 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 300 | DEVELOPMENT_TEAM = DBTR8NXFB4; 301 | INFOPLIST_FILE = GSImageViewerControllerExample/Info.plist; 302 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 303 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 304 | PRODUCT_BUNDLE_IDENTIFIER = me.gesen.GSImageViewerControllerExample; 305 | PRODUCT_NAME = "$(TARGET_NAME)"; 306 | SWIFT_VERSION = 5.0; 307 | }; 308 | name = Debug; 309 | }; 310 | 187BB8DA1C29089A00F5B7E5 /* Release */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 314 | DEVELOPMENT_TEAM = DBTR8NXFB4; 315 | INFOPLIST_FILE = GSImageViewerControllerExample/Info.plist; 316 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 317 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 318 | PRODUCT_BUNDLE_IDENTIFIER = me.gesen.GSImageViewerControllerExample; 319 | PRODUCT_NAME = "$(TARGET_NAME)"; 320 | SWIFT_VERSION = 5.0; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 187BB8C11C29089A00F5B7E5 /* Build configuration list for PBXProject "GSImageViewerControllerExample" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 187BB8D61C29089A00F5B7E5 /* Debug */, 331 | 187BB8D71C29089A00F5B7E5 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | 187BB8D81C29089A00F5B7E5 /* Build configuration list for PBXNativeTarget "GSImageViewerControllerExample" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 187BB8D91C29089A00F5B7E5 /* Debug */, 340 | 187BB8DA1C29089A00F5B7E5 /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | /* End XCConfigurationList section */ 346 | }; 347 | rootObject = 187BB8BE1C29089A00F5B7E5 /* Project object */; 348 | } 349 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wxxsw/GSImageViewerController/005360c794b5c6d484fb187f37a42c5633e6be76/GSImageViewerControllerExample/GSImageViewerControllerExample/0.jpg -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wxxsw/GSImageViewerController/005360c794b5c6d484fb187f37a42c5633e6be76/GSImageViewerControllerExample/GSImageViewerControllerExample/1.jpg -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wxxsw/GSImageViewerController/005360c794b5c6d484fb187f37a42c5633e6be76/GSImageViewerControllerExample/GSImageViewerControllerExample/2.jpg -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GSImageViewerControllerExample 4 | // 5 | // Created by Gesen on 15/12/22. 6 | // Copyright © 2015年 Gesen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 45 | 56 | 63 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /GSImageViewerControllerExample/GSImageViewerControllerExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // GSImageViewerControllerExample 4 | // 5 | // Created by Gesen on 15/12/22. 6 | // Copyright © 2015年 Gesen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | } 16 | 17 | @IBAction func normalPush(_ sender: AnyObject) { 18 | let imageInfo = GSImageInfo(image: UIImage(named: "0.jpg")!, imageMode: .aspectFit) 19 | let imageViewer = GSImageViewerController(imageInfo: imageInfo) 20 | navigationController?.pushViewController(imageViewer, animated: true) 21 | } 22 | 23 | @IBAction func normalPresent(_ sender: AnyObject) { 24 | let imageInfo = GSImageInfo(image: UIImage(named: "0.jpg")!, imageMode: .aspectFill) 25 | let imageViewer = GSImageViewerController(imageInfo: imageInfo) 26 | present(imageViewer, animated: true, completion: nil) 27 | } 28 | 29 | @IBAction func customPresent(_ sender: UIButton) { 30 | let imageInfo = GSImageInfo(image: UIImage(named: "1.jpg")!, imageMode: .aspectFill) 31 | let transitionInfo = GSTransitionInfo(fromView: sender) 32 | let imageViewer = GSImageViewerController(imageInfo: imageInfo, transitionInfo: transitionInfo) 33 | present(imageViewer, animated: true, completion: nil) 34 | } 35 | 36 | @IBAction func cornerRadiusPresent(_ sender: UIButton) { 37 | let imageInfo = GSImageInfo(image: UIImage(named: "2.jpg")!, imageMode: .aspectFit) 38 | let transitionInfo = GSTransitionInfo(fromView: sender) 39 | let imageViewer = GSImageViewerController(imageInfo: imageInfo, transitionInfo: transitionInfo) 40 | 41 | imageViewer.dismissCompletion = { 42 | print("dismissCompletion") 43 | } 44 | 45 | present(imageViewer, animated: true, completion: nil) 46 | } 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ge Sen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "GSImageViewerController", 6 | platforms: [.iOS(.v8)], 7 | products: [ 8 | .library(name: "GSImageViewerController", targets: ["GSImageViewerController"]) 9 | ], 10 | targets: [ 11 | .target(name: "GSImageViewerController", path: "GSImageViewerController") 12 | ] 13 | ) 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GSImageViewerController 2 | 3 | ## Demo 4 | 5 | ![](https://github.com/wxxsw/GSImageViewerController/blob/master/demo.gif) 6 | 7 | ## Example 8 | 9 | To show normal image viewer controller: 10 | ```Swift 11 | let imageInfo = GSImageInfo(image: someImage, imageMode: .aspectFit) 12 | let imageViewer = GSImageViewerController(imageInfo: imageInfo) 13 | navigationController?.pushViewController(imageViewer, animated: true) 14 | ``` 15 | 16 | To show zoom transition image viewer controller: 17 | ```Swift 18 | let imageInfo = GSImageInfo(image: someImage, imageMode: .aspectFill, imageHD: someHDImageURLOrNil) 19 | let transitionInfo = GSTransitionInfo(fromView: someView) 20 | let imageViewer = GSImageViewerController(imageInfo: imageInfo, transitionInfo: transitionInfo) 21 | present(imageViewer, animated: true, completion: nil) 22 | ``` 23 | 24 | ## Requirements 25 | 26 | ### Master 27 | 28 | - iOS 8.0+ 29 | - Xcode 10.2+ (Swift 5) 30 | 31 | ### [1.5.2](https://github.com/wxxsw/GSImageViewerController/tree/1.5.2) 32 | 33 | - iOS 8.0+ 34 | - Xcode 10 (Swift 4.2) 35 | 36 | ### [1.4.2](https://github.com/wxxsw/GSImageViewerController/tree/1.4.2) 37 | 38 | - iOS 8.0+ 39 | - Xcode 9 (Swift 4) 40 | 41 | ### [1.2.1](https://github.com/wxxsw/GSImageViewerController/tree/1.2.1) 42 | 43 | - iOS 8.0+ 44 | - Xcode 8 (Swift 3) 45 | 46 | ### [1.1.1](https://github.com/wxxsw/GSImageViewerController/tree/1.1.1) 47 | 48 | - iOS 7.0+ 49 | - Xcode 7 (Swift 2) 50 | 51 | ## Installation 52 | 53 | ### [CocoaPods](http://cocoapods.org/): 54 | 55 | In your `Podfile`: 56 | ``` 57 | source 'https://github.com/CocoaPods/Specs.git' 58 | platform :ios, '8.0' 59 | use_frameworks! 60 | 61 | pod "GSImageViewerController" 62 | ``` 63 | 64 | And in your `*.swift`: 65 | ```swift 66 | import GSImageViewerController 67 | ``` 68 | 69 | ## License 70 | 71 | GSImageViewerController is available under the MIT license. See the LICENSE file for more info. 72 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wxxsw/GSImageViewerController/005360c794b5c6d484fb187f37a42c5633e6be76/demo.gif --------------------------------------------------------------------------------