File tree Expand file tree Collapse file tree 5 files changed +30
-12
lines changed
Expand file tree Collapse file tree 5 files changed +30
-12
lines changed Original file line number Diff line number Diff line change 11# Change log
22
3+ ## [ Version 2.0.4] ( https://github.com/efremidze/Magnetic/releases/tag/2.0.4 )
4+ Released on 2017-12-13
5+
6+ - Image bugs fix
7+
38## [ Version 2.0.3] ( https://github.com/efremidze/Magnetic/releases/tag/2.0.3 )
49Released on 2017-12-10
510
Original file line number Diff line number Diff line change 88
99Pod ::Spec . new do |s |
1010 s . name = 'Magnetic'
11- s . version = '2.0.3 '
11+ s . version = '2.0.4 '
1212 s . summary = 'SpriteKit Floating Bubble Picker (inspired by Apple Music)'
1313 s . homepage = 'https://github.com/efremidze/Magnetic'
1414 s . license = { :type => 'MIT' , :file => 'LICENSE' }
Original file line number Diff line number Diff line change @@ -20,13 +20,24 @@ extension CGPoint {
2020 }
2121}
2222
23- extension SKSpriteNode {
24- func aspectFill( size: CGSize ) {
25- let _size = self . size
26- let verticalRatio = _size. height / size. height
27- let horizontalRatio = _size. width / size. width
28- let scaleRatio = horizontalRatio > verticalRatio ? horizontalRatio : verticalRatio
29- self . setScale ( scaleRatio)
30- self . size = size
23+ extension UIImage {
24+ func aspectFill( _ size: CGSize ) -> UIImage {
25+ let aspectWidth = size. width / self . size. width
26+ let aspectHeight = size. height / self . size. height
27+ let aspectRatio = max ( aspectWidth, aspectHeight)
28+
29+ var newSize = self . size
30+ newSize. width *= aspectRatio
31+ newSize. height *= aspectRatio
32+ return resize ( newSize)
33+ }
34+ func resize( _ size: CGSize ) -> UIImage {
35+ var rect = CGRect . zero
36+ rect. size = size
37+ UIGraphicsBeginImageContextWithOptions ( size, false , scale)
38+ draw ( in: rect)
39+ let image = UIGraphicsGetImageFromCurrentImageContext ( )
40+ UIGraphicsEndImageContext ( )
41+ return image!
3142 }
3243}
Original file line number Diff line number Diff line change 1515 <key >CFBundlePackageType </key >
1616 <string >FMWK </string >
1717 <key >CFBundleShortVersionString </key >
18- <string >2.0.3 </string >
18+ <string >2.0.4 </string >
1919 <key >CFBundleVersion </key >
2020 <string >$(CURRENT_PROJECT_VERSION) </string >
2121 <key >NSPrincipalClass </key >
Original file line number Diff line number Diff line change @@ -43,8 +43,10 @@ open class Node: MaskNode {
4343 */
4444 open var image : UIImage ? {
4545 didSet {
46- texture = image. map { SKTexture ( image: $0) }
47- sprite. aspectFill ( size: texture? . size ( ) ?? self . frame. size)
46+ // let url = URL(string: "https://picsum.photos/1200/600")!
47+ // let image = UIImage(data: try! Data(contentsOf: url))
48+ texture = image. map { SKTexture ( image: $0. aspectFill ( self . frame. size) ) }
49+ sprite. size = texture? . size ( ) ?? self . frame. size
4850 }
4951 }
5052
You can’t perform that action at this time.
0 commit comments