@@ -642,21 +642,8 @@ - (void)createViews
642
642
self.addressLabel .textColor = [UIColor colorWithWhite: 1.000 alpha: 1.000 ];
643
643
self.addressLabel .userInteractionEnabled = NO ;
644
644
645
- NSString * frontArrowString = NSLocalizedString(@" ►" , nil ); // create arrow from Unicode char
646
- self.forwardButton = [[UIBarButtonItem alloc ] initWithTitle: frontArrowString style: UIBarButtonItemStylePlain target: self action: @selector (goForward: )];
647
- self.forwardButton .enabled = YES ;
648
- self.forwardButton .imageInsets = UIEdgeInsetsZero;
649
- if (_browserOptions.navigationbuttoncolor != nil ) { // Set button color if user sets it in options
650
- self.forwardButton .tintColor = [self colorFromHexString: _browserOptions.navigationbuttoncolor];
651
- }
652
-
653
- NSString * backArrowString = NSLocalizedString(@" ◄" , nil ); // create arrow from Unicode char
654
- self.backButton = [[UIBarButtonItem alloc ] initWithTitle: backArrowString style: UIBarButtonItemStylePlain target: self action: @selector (goBack: )];
655
- self.backButton .enabled = YES ;
656
- self.backButton .imageInsets = UIEdgeInsetsZero;
657
- if (_browserOptions.navigationbuttoncolor != nil ) { // Set button color if user sets it in options
658
- self.backButton .tintColor = [self colorFromHexString: _browserOptions.navigationbuttoncolor];
659
- }
645
+ self.forwardButton = [self buildForwardButton ];
646
+ self.backButton = [self buildBackButton ];
660
647
661
648
// Filter out Navigation Buttons if user requests so
662
649
if (_browserOptions.hidenavigationbuttons ) {
@@ -676,6 +663,63 @@ - (void) setWebViewFrame : (CGRect) frame {
676
663
[self .webView setFrame: frame];
677
664
}
678
665
666
+ - (UIBarButtonItem*)buildForwardButton
667
+ {
668
+ UIImage *forwardArrow = [self drawForwardArrow ];
669
+ UIBarButtonItem *forwardButton = [[UIBarButtonItem alloc ] initWithImage: forwardArrow style: UIBarButtonItemStylePlain target: self action: @selector (goForward: )];
670
+ forwardButton.enabled = YES ;
671
+ forwardButton.imageInsets = UIEdgeInsetsZero;
672
+
673
+ if (_browserOptions.navigationbuttoncolor != nil ) { // Set button color if user sets it in options
674
+ forwardButton.tintColor = [self colorFromHexString: _browserOptions.navigationbuttoncolor];
675
+ }
676
+
677
+ return forwardButton;
678
+ }
679
+
680
+ - (UIBarButtonItem*)buildBackButton
681
+ {
682
+ UIImage *backArrow = [self drawBackArrow ];
683
+ UIBarButtonItem *backButton = [[UIBarButtonItem alloc ] initWithImage: backArrow style: UIBarButtonItemStylePlain target: self action: @selector (goBack: )];
684
+ backButton.enabled = YES ;
685
+ backButton.imageInsets = UIEdgeInsetsZero;
686
+
687
+ if (_browserOptions.navigationbuttoncolor != nil ) { // Set button color if user sets it in options
688
+ backButton.tintColor = [self colorFromHexString: _browserOptions.navigationbuttoncolor];
689
+ }
690
+
691
+ return backButton;
692
+ }
693
+
694
+ - (UIImage*)drawForwardArrow
695
+ {
696
+ CGSize canvasSize = CGSizeMake (20 ,20 );
697
+ CGFloat scale = [UIScreen mainScreen ].scale ;
698
+
699
+ canvasSize.width *= scale;
700
+ canvasSize.height *= scale;
701
+
702
+ UIGraphicsBeginImageContextWithOptions (canvasSize, false , 0 );
703
+ CGContextRef context = UIGraphicsGetCurrentContext ();
704
+
705
+ CGContextBeginPath (context);
706
+ CGContextMoveToPoint ( context, canvasSize.width * 3.0 /10.0 , canvasSize.height * 2.8 /10.0 );
707
+ CGContextAddLineToPoint (context, canvasSize.width * 5.0 /10.0 , canvasSize.height * 5.0 /10.0 );
708
+ CGContextAddLineToPoint (context, canvasSize.width * 3.0 /10.0 , canvasSize.height * 7.2 /10.0 );
709
+
710
+ CGContextSetLineWidth (context, (scale > 1.0 ? 0.75 * scale : 1.0 ));
711
+ CGContextSetStrokeColorWithColor (context, [UIColor blackColor ].CGColor );
712
+ CGContextStrokePath (context);
713
+
714
+ return UIGraphicsGetImageFromCurrentImageContext ();
715
+ }
716
+
717
+ -(UIImage*)drawBackArrow
718
+ {
719
+ UIImage *forwardArrow = [self drawForwardArrow ];
720
+ return [UIImage imageWithCGImage: forwardArrow.CGImage scale: forwardArrow.scale orientation: UIImageOrientationUpMirrored];
721
+ }
722
+
679
723
- (void )setCloseButtonTitle : (NSString *)title : (NSString *) colorString
680
724
{
681
725
// the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
@@ -898,8 +942,8 @@ - (float) getStatusBarOffset {
898
942
}
899
943
900
944
- (void ) rePositionViews {
901
- if ([_browserOptions.toolbarposition isEqualToString: kInAppBrowserToolbarBarPositionTop ]) {
902
- [self .webView setFrame: CGRectMake (self .webView.frame.origin.x, TOOLBAR_HEIGHT, self .webView.frame.size.width, self .webView.frame.size.height)];
945
+ if ((_browserOptions. toolbar ) && ( [_browserOptions.toolbarposition isEqualToString: kInAppBrowserToolbarBarPositionTop ]) ) {
946
+ [self .webView setFrame: CGRectMake (self .webView.frame.origin.x, TOOLBAR_HEIGHT + [ self getStatusBarOffset ] , self .webView.frame.size.width, self .webView.frame.size.height - [ self getStatusBarOffset ] )];
903
947
[self .toolbar setFrame: CGRectMake (self .toolbar.frame.origin.x, [self getStatusBarOffset ], self .toolbar.frame.size.width, self .toolbar.frame.size.height)];
904
948
}
905
949
}
0 commit comments