@@ -105,9 +105,9 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
105105 self . view. addSubview ( bottomView)
106106 topView. translatesAutoresizingMaskIntoConstraints = false
107107 bottomView. translatesAutoresizingMaskIntoConstraints = false
108- let horizontalTopConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : topView] )
109- let horizontalBottomConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : bottomView] )
110- let verticalConst = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(0)-[top]-(0)-[bottom(70)]-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " bottom " : bottomView, " top " : topView] )
108+ let horizontalTopConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : topView] )
109+ let horizontalBottomConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : bottomView] )
110+ let verticalConst = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(0)-[top]-(0)-[bottom(70)]-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " bottom " : bottomView, " top " : topView] )
111111 self . view. addConstraints ( horizontalTopConst + horizontalBottomConst + verticalConst)
112112
113113 // image view
@@ -138,8 +138,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
138138 fadeView. isUserInteractionEnabled = false
139139 fadeView. backgroundColor = UIColor . black. withAlphaComponent ( 0.3 )
140140 topView. addSubview ( fadeView)
141- let horizontalFadeConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : fadeView] )
142- let verticalFadeConst = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(0)-[view]-(0)-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : fadeView] )
141+ let horizontalFadeConst = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(0)-[view]-(0)-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : fadeView] )
142+ let verticalFadeConst = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(0)-[view]-(0)-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : fadeView] )
143143 topView. addConstraints ( horizontalFadeConst + verticalFadeConst)
144144
145145 // crop overlay
@@ -177,7 +177,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
177177 let centerCropYConst = NSLayoutConstraint ( item: cropButton, attribute: . centerY, relatedBy: . equal, toItem: bottomView, attribute: . centerY, multiplier: 1 , constant: 0 )
178178 bottomView. addConstraints ( [ centerCropXConst, centerCropYConst] )
179179
180- self . view. bringSubview ( toFront : bottomView)
180+ self . view. bringSubviewToFront ( bottomView)
181181
182182 bottomView. layoutIfNeeded ( )
183183 topView. layoutIfNeeded ( )
@@ -209,8 +209,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
209209 imageHeightConst? . constant = cropView. frame. width * ratio
210210 }
211211
212- let horizontal = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(<= \( cropView. frame. origin. x) )-[view]-(<= \( cropView. frame. origin. x) )-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : imageView] )
213- let vertical = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(<= \( cropView. frame. origin. y) )-[view]-(<= \( cropView. frame. origin. y) )-| " , options: NSLayoutFormatOptions ( ) , metrics: nil , views: [ " view " : imageView] )
212+ let horizontal = NSLayoutConstraint . constraints ( withVisualFormat: " H:|-(<= \( cropView. frame. origin. x) )-[view]-(<= \( cropView. frame. origin. x) )-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : imageView] )
213+ let vertical = NSLayoutConstraint . constraints ( withVisualFormat: " V:|-(<= \( cropView. frame. origin. y) )-[view]-(<= \( cropView. frame. origin. y) )-| " , options: NSLayoutConstraint . FormatOptions ( ) , metrics: nil , views: [ " view " : imageView] )
214214 topView. addConstraints ( horizontal + vertical)
215215
216216 maskFadeView ( )
@@ -222,7 +222,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
222222 let path = UIBezierPath ( rect: cropView. frame)
223223 path. append ( UIBezierPath ( rect: fadeView. frame) )
224224 let mask = CAShapeLayer ( )
225- mask. fillRule = kCAFillRuleEvenOdd
225+ mask. fillRule = CAShapeLayerFillRule . evenOdd
226226 mask. path = path. cgPath
227227 fadeView. layer. mask = mask
228228 }
@@ -240,7 +240,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
240240 } else {
241241 self . endAppearanceTransition ( )
242242 self . view. removeFromSuperview ( )
243- self . removeFromParentViewController ( )
243+ self . removeFromParent ( )
244244 if self . autoClosePicker {
245245 self . picker? . dismiss ( animated: true , completion: nil )
246246 }
@@ -255,7 +255,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
255255 } else {
256256 self . endAppearanceTransition ( )
257257 self . view. removeFromSuperview ( )
258- self . removeFromParentViewController ( )
258+ self . removeFromParent ( )
259259 }
260260 }
261261
@@ -312,22 +312,22 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
312312
313313 var presenting = false
314314
315- public func imagePickerController( _ picker: UIImagePickerController , didFinishPickingMediaWithInfo info: [ String : Any ] ) {
315+ public func imagePickerController( _ picker: UIImagePickerController , didFinishPickingMediaWithInfo info: [ UIImagePickerController . InfoKey : Any ] ) {
316316 guard !presenting else {
317317 return
318318 }
319- guard let image = info [ UIImagePickerControllerOriginalImage ] as? UIImage else {
319+ guard let image = info [ UIImagePickerController . InfoKey . originalImage ] as? UIImage else {
320320 return
321321 }
322322 layoutDone = false
323323 presenting = true
324324 self . image = image. fixOrientation ( )
325325 self . picker? . view. addSubview ( self . view)
326326 self . view. constraintToFill ( superView: self . picker? . view)
327- self . picker? . addChildViewController ( self )
328- self . willMove ( toParentViewController : self . picker)
327+ self . picker? . addChild ( self )
328+ self . willMove ( toParent : self . picker)
329329 self . beginAppearanceTransition ( true , animated: false )
330- }
330+ }
331331
332332}
333333
0 commit comments