1
1
2
2
import UIKit
3
- func imageFromContextOfSize ( size: CGSize , closure: ( ) -> ( ) ) -> UIImage {
3
+ func imageOfSize ( size: CGSize , closure: ( ) -> ( ) ) -> UIImage {
4
4
UIGraphicsBeginImageContextWithOptions ( size, false , 0 )
5
5
closure ( )
6
6
let result = UIGraphicsGetImageFromCurrentImageContext ( )
@@ -20,27 +20,27 @@ class ViewController: UIViewController {
20
20
21
21
let sz = CGSizeMake ( 20 , 20 )
22
22
23
- self . navbar. setBackgroundImage ( imageFromContextOfSize ( sz) {
23
+ self . navbar. setBackgroundImage ( imageOfSize ( sz) {
24
24
UIColor ( white: 0.95 , alpha: 0.85 ) . setFill ( )
25
25
CGContextFillRect ( UIGraphicsGetCurrentContext ( ) , CGRectMake ( 0 , 0 , 20 , 20 ) )
26
26
} , forBarPosition: . Any, barMetrics: . Default)
27
27
self . navbar. translucent = true
28
28
29
- self . toolbar. setBackgroundImage ( imageFromContextOfSize ( sz) {
29
+ self . toolbar. setBackgroundImage ( imageOfSize ( sz) {
30
30
UIColor ( white: 0.95 , alpha: 0.85 ) . setFill ( )
31
31
CGContextFillRect ( UIGraphicsGetCurrentContext ( ) , CGRectMake ( 0 , 0 , 20 , 20 ) )
32
32
} , forToolbarPosition: . Any, barMetrics: . Default)
33
33
self . navbar. translucent = true
34
34
35
35
let sz2 = CGSizeMake ( 4 , 4 )
36
36
37
- self . navbar. shadowImage = imageFromContextOfSize ( sz2) {
37
+ self . navbar. shadowImage = imageOfSize ( sz2) {
38
38
UIColor . grayColor ( ) . colorWithAlphaComponent ( 0.3 ) . setFill ( )
39
39
CGContextFillRect ( UIGraphicsGetCurrentContext ( ) , CGRectMake ( 0 , 0 , 4 , 2 ) )
40
40
UIColor . grayColor ( ) . colorWithAlphaComponent ( 0.15 ) . setFill ( )
41
41
CGContextFillRect ( UIGraphicsGetCurrentContext ( ) , CGRectMake ( 0 , 2 , 4 , 2 ) )
42
42
}
43
- self . toolbar. setShadowImage ( imageFromContextOfSize ( sz2) {
43
+ self . toolbar. setShadowImage ( imageOfSize ( sz2) {
44
44
UIColor . grayColor ( ) . colorWithAlphaComponent ( 0.3 ) . setFill ( )
45
45
CGContextFillRect ( UIGraphicsGetCurrentContext ( ) , CGRectMake ( 0 , 2 , 4 , 2 ) )
46
46
UIColor . grayColor ( ) . colorWithAlphaComponent ( 0.15 ) . setFill ( )
0 commit comments