@@ -466,23 +466,16 @@ + (UIImage *)doneImage
466
466
withConfiguration: [UIImageSymbolConfiguration configurationWithWeight: UIImageSymbolWeightSemibold]];
467
467
}
468
468
469
- UIImage *doneImage = nil ;
470
-
471
- UIGraphicsBeginImageContextWithOptions ((CGSize){17 ,14 }, NO , 0 .0f );
472
- {
473
- // // Rectangle Drawing
469
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: (CGSize){17 ,14 }];
470
+ UIImage *doneImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
474
471
UIBezierPath* rectanglePath = UIBezierPath.bezierPath ;
475
472
[rectanglePath moveToPoint: CGPointMake (1 , 7 )];
476
473
[rectanglePath addLineToPoint: CGPointMake (6 , 12 )];
477
474
[rectanglePath addLineToPoint: CGPointMake (16 , 1 )];
478
475
[UIColor.whiteColor setStroke ];
479
476
rectanglePath.lineWidth = 2 ;
480
477
[rectanglePath stroke ];
481
-
482
-
483
- doneImage = UIGraphicsGetImageFromCurrentImageContext ();
484
- }
485
- UIGraphicsEndImageContext ();
478
+ }];
486
479
487
480
return doneImage;
488
481
}
@@ -494,29 +487,22 @@ + (UIImage *)cancelImage
494
487
withConfiguration: [UIImageSymbolConfiguration configurationWithWeight: UIImageSymbolWeightSemibold]];
495
488
}
496
489
497
- UIImage *cancelImage = nil ;
498
-
499
- UIGraphicsBeginImageContextWithOptions ((CGSize){16 ,16 }, NO , 0 .0f );
500
- {
490
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: (CGSize){16 ,16 }];
491
+ UIImage *cancelImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
501
492
UIBezierPath* bezierPath = UIBezierPath.bezierPath ;
502
493
[bezierPath moveToPoint: CGPointMake (15 , 15 )];
503
494
[bezierPath addLineToPoint: CGPointMake (1 , 1 )];
504
495
[UIColor.whiteColor setStroke ];
505
496
bezierPath.lineWidth = 2 ;
506
497
[bezierPath stroke ];
507
-
508
-
509
- // // Bezier 2 Drawing
498
+
510
499
UIBezierPath* bezier2Path = UIBezierPath.bezierPath ;
511
500
[bezier2Path moveToPoint: CGPointMake (1 , 15 )];
512
501
[bezier2Path addLineToPoint: CGPointMake (15 , 1 )];
513
502
[UIColor.whiteColor setStroke ];
514
503
bezier2Path.lineWidth = 2 ;
515
504
[bezier2Path stroke ];
516
-
517
- cancelImage = UIGraphicsGetImageFromCurrentImageContext ();
518
- }
519
- UIGraphicsEndImageContext ();
505
+ }];
520
506
521
507
return cancelImage;
522
508
}
@@ -529,17 +515,12 @@ + (UIImage *)rotateCCWImage
529
515
imageWithBaselineOffsetFromBottom: 4 ];
530
516
}
531
517
532
- UIImage *rotateImage = nil ;
533
-
534
- UIGraphicsBeginImageContextWithOptions ((CGSize){18 ,21 }, NO , 0 .0f );
535
- {
536
- // // Rectangle 2 Drawing
518
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: (CGSize){18 ,21 }];
519
+ UIImage *rotateImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
537
520
UIBezierPath* rectangle2Path = [UIBezierPath bezierPathWithRect: CGRectMake (0 , 9 , 12 , 12 )];
538
521
[UIColor.whiteColor setFill ];
539
522
[rectangle2Path fill ];
540
-
541
-
542
- // // Rectangle 3 Drawing
523
+
543
524
UIBezierPath* rectangle3Path = UIBezierPath.bezierPath ;
544
525
[rectangle3Path moveToPoint: CGPointMake (5 , 3 )];
545
526
[rectangle3Path addLineToPoint: CGPointMake (10 , 6 )];
@@ -548,19 +529,15 @@ + (UIImage *)rotateCCWImage
548
529
[rectangle3Path closePath ];
549
530
[UIColor.whiteColor setFill ];
550
531
[rectangle3Path fill ];
551
-
552
-
553
- // // Bezier Drawing
532
+
554
533
UIBezierPath* bezierPath = UIBezierPath.bezierPath ;
555
534
[bezierPath moveToPoint: CGPointMake (10 , 3 )];
556
535
[bezierPath addCurveToPoint: CGPointMake (17.5 , 11 ) controlPoint1: CGPointMake (15 , 3 ) controlPoint2: CGPointMake (17.5 , 5.91 )];
557
536
[UIColor.whiteColor setStroke ];
558
537
bezierPath.lineWidth = 1 ;
559
538
[bezierPath stroke ];
560
- rotateImage = UIGraphicsGetImageFromCurrentImageContext ();
561
- }
562
- UIGraphicsEndImageContext ();
563
-
539
+ }];
540
+
564
541
return rotateImage;
565
542
}
566
543
@@ -573,13 +550,14 @@ + (UIImage *)rotateCWImage
573
550
}
574
551
575
552
UIImage *rotateCCWImage = [self .class rotateCCWImage ];
576
- UIGraphicsBeginImageContextWithOptions (rotateCCWImage.size , NO , rotateCCWImage.scale );
577
- CGContextRef context = UIGraphicsGetCurrentContext ();
578
- CGContextTranslateCTM (context, rotateCCWImage.size .width , rotateCCWImage.size .height );
579
- CGContextRotateCTM (context, M_PI);
580
- CGContextDrawImage (context,CGRectMake (0 ,0 ,rotateCCWImage.size .width ,rotateCCWImage.size .height ),rotateCCWImage.CGImage );
581
- UIImage *rotateCWImage = UIGraphicsGetImageFromCurrentImageContext ();
582
- UIGraphicsEndImageContext ();
553
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: rotateCCWImage.size];
554
+ UIImage *rotateCWImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
555
+ CGContextRef context = rendererContext.CGContext ;
556
+ CGContextTranslateCTM (context, rotateCCWImage.size .width , rotateCCWImage.size .height );
557
+ CGContextRotateCTM (context, M_PI);
558
+ CGContextDrawImage (context,CGRectMake (0 ,0 ,rotateCCWImage.size .width ,rotateCCWImage.size .height ),rotateCCWImage.CGImage );
559
+ }];
560
+
583
561
return rotateCWImage;
584
562
}
585
563
@@ -591,12 +569,8 @@ + (UIImage *)resetImage
591
569
imageWithBaselineOffsetFromBottom: 0 ];;
592
570
}
593
571
594
- UIImage *resetImage = nil ;
595
-
596
- UIGraphicsBeginImageContextWithOptions ((CGSize){22 ,18 }, NO , 0 .0f );
597
- {
598
-
599
- // // Bezier 2 Drawing
572
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: (CGSize){22 ,18 }];
573
+ UIImage *resetImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
600
574
UIBezierPath* bezier2Path = UIBezierPath.bezierPath ;
601
575
[bezier2Path moveToPoint: CGPointMake (22 , 9 )];
602
576
[bezier2Path addCurveToPoint: CGPointMake (13 , 18 ) controlPoint1: CGPointMake (22 , 13.97 ) controlPoint2: CGPointMake (17.97 , 18 )];
@@ -613,9 +587,7 @@ + (UIImage *)resetImage
613
587
[bezier2Path closePath ];
614
588
[UIColor.whiteColor setFill ];
615
589
[bezier2Path fill ];
616
-
617
-
618
- // // Polygon Drawing
590
+
619
591
UIBezierPath* polygonPath = UIBezierPath.bezierPath ;
620
592
[polygonPath moveToPoint: CGPointMake (5 , 15 )];
621
593
[polygonPath addLineToPoint: CGPointMake (10 , 9 )];
@@ -624,11 +596,7 @@ + (UIImage *)resetImage
624
596
[polygonPath closePath ];
625
597
[UIColor.whiteColor setFill ];
626
598
[polygonPath fill ];
627
-
628
-
629
- resetImage = UIGraphicsGetImageFromCurrentImageContext ();
630
- }
631
- UIGraphicsEndImageContext ();
599
+ }];
632
600
633
601
return resetImage;
634
602
}
@@ -640,46 +608,38 @@ + (UIImage *)clampImage
640
608
withConfiguration: [UIImageSymbolConfiguration configurationWithWeight: UIImageSymbolWeightSemibold]]
641
609
imageWithBaselineOffsetFromBottom: 0 ];
642
610
}
643
-
644
- UIImage *clampImage = nil ;
645
611
646
- UIGraphicsBeginImageContextWithOptions (( CGSize){22 ,16 }, NO , 0 . 0f ) ;
647
- {
612
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc ] initWithSize: ( CGSize){22 ,16 }] ;
613
+ UIImage *clampImage = [renderer imageWithActions: ^(UIGraphicsImageRendererContext *rendererContext) {
648
614
// // Color Declarations
649
615
UIColor* outerBox = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.553 ];
650
616
UIColor* innerBox = [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 0.773 ];
651
-
617
+
652
618
// // Rectangle Drawing
653
619
UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRect: CGRectMake (0 , 3 , 13 , 13 )];
654
620
[UIColor.whiteColor setFill ];
655
621
[rectanglePath fill ];
656
-
657
-
622
+
658
623
// // Outer
659
624
{
660
625
// // Top Drawing
661
626
UIBezierPath* topPath = [UIBezierPath bezierPathWithRect: CGRectMake (0 , 0 , 22 , 2 )];
662
627
[outerBox setFill ];
663
628
[topPath fill ];
664
-
665
-
629
+
630
+
666
631
// // Side Drawing
667
632
UIBezierPath* sidePath = [UIBezierPath bezierPathWithRect: CGRectMake (19 , 2 , 3 , 14 )];
668
633
[outerBox setFill ];
669
634
[sidePath fill ];
670
635
}
671
-
672
-
636
+
673
637
// // Rectangle 2 Drawing
674
638
UIBezierPath* rectangle2Path = [UIBezierPath bezierPathWithRect: CGRectMake (14 , 3 , 4 , 13 )];
675
639
[innerBox setFill ];
676
640
[rectangle2Path fill ];
677
-
678
-
679
- clampImage = UIGraphicsGetImageFromCurrentImageContext ();
680
- }
681
- UIGraphicsEndImageContext ();
682
-
641
+ }];
642
+
683
643
return clampImage;
684
644
}
685
645
0 commit comments