Skip to content

Commit

Permalink
Fix cropToSquare screen density issues.
Browse files Browse the repository at this point in the history
Fix #9
  • Loading branch information
melvitax committed Dec 4, 2015
1 parent c8d9d49 commit cbfd1b7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build/
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
xcuserdata/
profile
*.moved-aside
DerivedData
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions AFImageHelper/AFImageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ public extension UIImage {
}

func cropToSquare() -> UIImage? {
let size = CGSizeMake(self.size.width * self.scale, self.size.height * self.scale)
let shortest = min(size.width, size.height)
let left: CGFloat = size.width > shortest ? (size.width-shortest)/2 : 0
let top: CGFloat = size.height > shortest ? (size.height-shortest)/2 : 0
Expand Down

0 comments on commit cbfd1b7

Please sign in to comment.