0

Im having issue where i just using a simple UIBarButton and named it "Send" and white tint color using Storyboard

In viewdidload, i use this code to change the tint color to red, but it stay to white color, and only change to red after i press it 1 time and also, it become a bit smaller @-@ , cant figure out whats the problem here, i dont have any code before that can change the button

- (void)viewDidLoad
{
    [super viewDidLoad];
    [_sendEPinButton setTintColor:[UIColor redColor]];

    center = [NSNotificationCenter defaultCenter];
    [center addObserver:self selector:@selector(keyboardOnScreen:) name:UIKeyboardWillShowNotification object:nil];
    [center addObserver:self selector:@selector(keyboardOffScreen:) name:UIKeyboardWillHideNotification object:nil];

    CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init];
    CTCarrier *carrier = [networkInfo subscriberCellularProvider];

    if (carrier.isoCountryCode.length == 0) {
        self.geocoder = [[CLGeocoder alloc] init];

        self.locationManager = [[CLLocationManager alloc] init];

        if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
            [self.locationManager requestAlwaysAuthorization];
        }

        self.locationManager.delegate = self;
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        [self.locationManager startMonitoringSignificantLocationChanges];
//        [self.locationManager startUpdatingLocation];
    } else {
        countryCodeString = carrier.isoCountryCode;
    }
    _contactTextfield.delegate = self;

    [_contactTextfield setTintColor:colorFromRGB(67, 160, 48)];
}

In .h file

@property (strong, nonatomic) IBOutlet UIBarButtonItem *sendEPinButton;

Before press enter image description here

After Press enter image description here

Tj3n
  • 9,837
  • 2
  • 24
  • 35

2 Answers2

1

Please put the code in ViewDidAppear method and see. Sometimes the outlets will not load properly in view did load method.

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109
0

you should write these line in viewdidload or where you created your UIBarButtonItem..

[_sendEPinButton setTintColor:[UIColor redColor]];
krushnsinh
  • 874
  • 1
  • 10
  • 11
  • Sorry, as i said, i really don't have any code that change the UIBarButtonItem before that line, the only thing that i did is create the button in storyboard and set tint to white and name it Send, thats all – Tj3n Sep 07 '15 at 11:45