11SwiftyImage
22===========
33
4- ![ Swift 2.0] ( https://img.shields.io/badge/Swift-2 .0-orange.svg )
4+ ![ Swift 2.0] ( https://img.shields.io/badge/Swift-3 .0-orange.svg )
55[ ![ CocoaPods] ( http://img.shields.io/cocoapods/v/SwiftyImage.svg?style=flat )] ( https://cocoapods.org/pods/SwiftyImage )
66
77The most sexy way to use images in Swift.
@@ -24,23 +24,23 @@ At a Glance
2424
2525``` swift
2626UIImage.size (width : 100 , height : 100 )
27- .color (UIColor.whiteColor ())
28- .border (color : UIColor.redColor ())
29- .border (width : 10 )
30- .corner (radius : 20 )
31- .image ()
27+ .color (UIColor.whiteColor ())
28+ .border (color : UIColor.redColor ())
29+ .border (width : 10 )
30+ .corner (radius : 20 )
31+ .image
3232```
3333
3434![ sample1] ( https://cloud.githubusercontent.com/assets/931655/8675848/106e59ea-2a81-11e5-8e4f-98cfea38bd8e.png )
3535
3636
3737``` swift
3838UIImage.resizable ()
39- .color (UIColor.whiteColor ())
40- .border (color : UIColor.blueColor ())
41- .border (width : 5 )
42- .corner (radius : 10 )
43- .image ()
39+ .color (UIColor.whiteColor ())
40+ .border (color : UIColor.blueColor ())
41+ .border (width : 5 )
42+ .corner (radius : 10 )
43+ .image
4444```
4545
4646![ sample2] ( https://cloud.githubusercontent.com/assets/931655/8675936/514b7f60-2a81-11e5-8806-26036d8e8ba5.png )
@@ -74,33 +74,33 @@ UIImage.resizable() // ...
7474You can set fill color, border attributes, corner radius, etc.
7575
7676``` swift
77- UIImage.size (width : 100 , height : 100 ) // fixed size
78- .color (UIColor.whiteColor ()) // fill color
79- .border (color : UIColor.redColor ()) // border color
80- .border (width : 10 ) // border width
81- .corner (radius : 20 ) // corner radius
77+ UIImage.size (width : 100 , height : 100 ) // fixed size
78+ .color (UIColor.whiteColor ()) // fill color
79+ .border (color : UIColor.redColor ()) // border color
80+ .border (width : 10 ) // border width
81+ .corner (radius : 20 ) // corner radius
8282```
8383
8484``` swift
8585UIImage.resizable () // resizable image
86- .color (UIColor.whiteColor ())
87- .border (color : UIColor.lightGrayColor ())
88- .border (width : 1 )
89- .corner (radius : 5 )
86+ .color (UIColor.whiteColor ())
87+ .border (color : UIColor.lightGrayColor ())
88+ .border (width : 1 )
89+ .corner (radius : 5 )
9090```
9191
9292
9393#### Step 3. Generating Image
9494
95- Use ` .image() ` at the end of method chaining to generate image.
95+ Use ` .image ` at the end of method chaining to generate image.
9696
9797``` swift
9898imageView.image = UIImage.size (width : 100 , height : 100 )
99- .color (UIColor.whiteColor ())
100- .border (color : UIColor.redColor ())
101- .border (width : 10 )
102- .corner (radius : 20 )
103- .image () // generate UIImage
99+ .color (UIColor.whiteColor ())
100+ .border (color : UIColor.redColor ())
101+ .border (width : 10 )
102+ .corner (radius : 20 )
103+ .image // generate UIImage
104104```
105105
106106
@@ -127,7 +127,7 @@ imageView.image = UIImage.size(width: 100, height: 100)
127127
128128| Generating Image Method | Description |
129129| ---| ---|
130- | ` .image() ` | Generate and return image |
130+ | ` .image ` | Generate and return image |
131131
132132
133133Play with CGContext
@@ -139,8 +139,8 @@ SwiftyImage also provides a simple method to create or manipulate images with CG
139139
140140``` swift
141141let image = UIImage.with (size : CGSize (width : 100 , height : 100 )) { context in
142- UIColor.lightGrayColor ().setFill ()
143- CGContextFillEllipseInRect (context, CGRect (x : 0 , y : 0 , width : 100 , height : 100 ))
142+ UIColor.lightGrayColor ().setFill ()
143+ CGContextFillEllipseInRect (context, CGRect (x : 0 , y : 0 , width : 100 , height : 100 ))
144144}
145145```
146146
@@ -149,8 +149,8 @@ let image = UIImage.with(size: CGSize(width: 100, height: 100)) { context in
149149
150150``` swift
151151let newImage = oldImage.with { context in
152- UIColor.lightGrayColor ().setFill ()
153- CGContextFillEllipseInRect (context, CGRect (x : 0 , y : 0 , width : 100 , height : 100 ))
152+ UIColor.lightGrayColor ().setFill ()
153+ CGContextFillEllipseInRect (context, CGRect (x : 0 , y : 0 , width : 100 , height : 100 ))
154154}
155155```
156156
0 commit comments