Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
fixed layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
ikorich committed Feb 12, 2017
1 parent f2cf53c commit 499f56d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
21 changes: 13 additions & 8 deletions IGRPhotoTweaks/IGRPhotoTweakView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import UIKit
fileprivate var originalSize = CGSize.zero

fileprivate var manualZoomed = false
fileprivate var manualMove = false

// masks
fileprivate var topMask: UIView!
Expand Down Expand Up @@ -126,13 +127,15 @@ import UIKit
public override func layoutSubviews() {
super.layoutSubviews()

self.originalSize = self.maxBounds().size
self.scrollView.center = CGPoint(x: (self.frame.width / 2.0), y: self.centerY)

self.cropView.center = self.scrollView.center
self.checkScrollViewContentOffset();

self.cropViewDidStopCrop(self.cropView)
if !manualMove {
self.originalSize = self.maxBounds().size
self.scrollView.center = CGPoint(x: (self.frame.width / 2.0), y: self.centerY)

self.cropView.center = self.scrollView.center
self.checkScrollViewContentOffset();

self.cropViewDidStopCrop(self.cropView)
}
}

func maxBounds() -> CGRect {
Expand Down Expand Up @@ -286,7 +289,7 @@ import UIKit

// scale scroll view
let shouldScale: Bool = self.scrollView.contentSize.width / self.scrollView.bounds.size.width <= 1.0 ||
self.scrollView.contentSize.height / self.scrollView.bounds.size.height <= 1.0
self.scrollView.contentSize.height / self.scrollView.bounds.size.height <= 1.0
if !self.manualZoomed || shouldScale {
let zoom = self.scrollView.zoomScaleToBound()
self.scrollView.setZoomScale(zoom, animated: false)
Expand Down Expand Up @@ -369,6 +372,7 @@ extension IGRPhotoTweakView : IGRCropViewDelegate {

func cropViewDidStartCrop(_ cropView: IGRCropView) {
self.highlightMask(true, animate: true)
self.manualMove = true;
}

func cropViewDidMove(_ cropView: IGRCropView) {
Expand Down Expand Up @@ -440,5 +444,6 @@ extension IGRPhotoTweakView : IGRCropViewDelegate {
})

self.highlightMask(false, animate: true)
self.manualMove = false;
}
}
6 changes: 0 additions & 6 deletions IGRPhotoTweaks/IGRPhotoTweakViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ import Photos
self.view.sendSubview(toBack: self.photoView)
}

override open func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

photoView.layoutSubviews()
}

// MARK: - Public

open func changedAngel(value: CGFloat) {
Expand Down

0 comments on commit 499f56d

Please sign in to comment.