-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ScaleToFill factor fixes & added childContainerView #4
- Loading branch information
1 parent
a877d8f
commit b8070fc
Showing
8 changed files
with
157 additions
and
73 deletions.
There are no files selected for viewing
131 changes: 72 additions & 59 deletions
131
Example/Athlee-ImagePicker/Athlee-ImagePicker.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// CGAffineTransform.swift | ||
// Pods | ||
// | ||
// Created by mac on 27/11/2016. | ||
// | ||
// | ||
|
||
import UIKit | ||
|
||
public extension CGAffineTransform { | ||
public static func scalingFactor(toFill containerSize: CGSize, with contentSize: CGSize, atAngle angle: Double) -> Double { | ||
var theta = fabs(angle - 2 * .pi * trunc(angle / .pi / 2) - .pi) | ||
|
||
if theta > .pi / 2 { | ||
theta = fabs(.pi - theta) | ||
} | ||
|
||
let h = Double(contentSize.height) | ||
let H = Double(containerSize.height) | ||
let w = Double(contentSize.width) | ||
let W = Double(containerSize.width) | ||
|
||
let scale1 = (H * cos(theta) + W * sin(theta)) / min(H, h) | ||
let scale2 = (H * sin(theta) + W * cos(theta)) / min(W, w) | ||
|
||
let scalingFactor = max(scale1, scale2) | ||
|
||
return scalingFactor | ||
} | ||
|
||
func scaling(toFill containerSize: CGSize, with contentSize: CGSize, atAngle angle: Double) -> CGAffineTransform { | ||
let factor = CGFloat(CGAffineTransform.scalingFactor(toFill: containerSize, | ||
with: contentSize, | ||
atAngle: angle)) | ||
|
||
return self.scaledBy(x: factor, y: factor) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Radians.swift | ||
// Pods | ||
// | ||
// Created by mac on 27/11/2016. | ||
// | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Double { | ||
public func toRadians() -> Double { | ||
return self * .pi / 180.0 | ||
} | ||
} | ||
|
||
public extension Float { | ||
public func toRadians() -> Float { | ||
return self * .pi / 180 | ||
} | ||
} |