How to change alpha of uinavigation item - ios

Now,when I clicked backbutton,the alpha of leftbarbutton item changed.
But I don't want to change alpha of leftbarbutton's arrow when I clicked backbutton.
I uploaded picture which alpha is changed when i clicked back button.
How can i realize?

Initialise the UIBarButtonItem with a UIButton as its custom view, and set the the button's adjustsImageWhenHighlighted property to false.

Related

How to highlight the button in backgroundview when popupview appeared?

Is there any code for highlighting the button in backgroungview? If I Press the button it should be highlighted and also popupview should appear in the same screen.Like this image
While clicking , you just add the another button to UIWindow.... So u get the popup like appearance of button..

iOS: Remove gap between left uibarbuttonitems

I had setup two UIBarButtonItem on the left. Below is the screen shot of the wireframes of the screen, captured from debugging view hierarchy. Red box is the default back button and green box is the menu button.
From the screenshot, there is a gap between the back button image and menu button. The back button's view is occupying the extra space. I'm trying to figure out a way to get these two button close to each other.
I removed the "Back" text for the back button:
let backItem = UIBarButtonItem()
backItem.title = ""
self.backBarButtonItem = backItem
And added menu button:
let btn = UIBarButtonItem()
btn.customView = menu // it's a UIButton
self.leftItemsSupplementBackButton = true
self.leftBarButtonItem = menu
If it truly is the back buttons view, then just reduce the size of its views frame and you are good to go.
If it is an attribute of the main back bar button item they give you, then make a custom one that looks the same and give it the appropriate size.
If you are using a flexible space bar button item, then use a fixed space bar button item and set it appropriately.
You can also modify the value of a bar button view's location through the insetInPlace() that you use on the frame, but that will take some experimenting on the correct values to be used.
There are few options:
One is to insert an invisible bar button item and give it negative width like shown here https://stackoverflow.com/a/31804099/520810
Alternatively you can adjust image insets https://stackoverflow.com/a/22742322/520810

iOS change custom bar button text color when the button becomes available

So I have a registration page (and multiple other places through the registration process where this will be implemented) that has a Next button, which is set up as a custom UIButton dragged onto the nav bar. As users enter in their registration information, I want to change the color of the text from grey when it is unavailable, to a custom green color. I've read some other threads, such as this one , but they haven't been any help. I think I'm doing what they told me to correctly, but I'm getting different results than I want. Right now my code looks like this:
-(void)checkCompletion
{
if( emailEntered && passwordEntered && [_password.text length] >= 5)
{
[_nextBarButtonItem setEnabled:YES];
[_nextButton setEnabled:YES];
[_nextButton.titleLabel setTextColor:[UIColor customGreen]];
[_nextButton setTintColor:[UIColor customGreen]];
[_nextBarButtonItem setTintColor:[UIColor customGreen]];
nextAvailable = YES;
}
else
{
nextAvailable = NO;
}
}
_nextBarButtonItem is the barButtonItem, and _nextButton is the UIButton I dragged onto the navigation bar, which is underneath _nextBarBUttonItem in the hierarchy. customGreen is a category with its header file #include'd into my prefix.pch, as I use the color throughout the app. This function gets called when textfields return and when the password is edited, so I can make the button available before the return key is pressed if users don't want to dismiss the keyboard first.
I have tried several methods, such as making the button my customGreen on the storyboard and disabling both the barButtonItem and the button itself underneath the barButtonItem in the hierarchy, hoping it would grey it out, but the button is still green, you just can't press it. I made the button grey on the storyboard, then call this function, but the text ends up changing to white instead of the green color. I tried explicitly defining the color as I set it, but I get the same result. I do not want my back button to turn this green color, only the next button when it becomes available to press.
Any ideas what I'm doing wrong?

UIButton only shows tintColor on longPress

UIBarButtonItem changes its tintColor immediately on touchDown, but UIButton seems to wait for longPress before showing it's highlighted color...
What is the correct way to change a button's highlight color immediately on touchDown?

How can I show a back arrow in the master-view popover button for UISplitViewController in iOS 7?

In my detail VC, I am implementing this UISplitViewController delegate method:
- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc
It is then easy for me to set the title of the button, but the result is just a button with plain text, and no back arrow. I am looking to get something like the Mail app where the master popover button also has the back chevron.
How can I do this?
Create your custom bar button item, with the chevron image, set up as you want, and set the target and action of your bar button item to be that of the one passed by the delegate callback. This way, your bar button will perform the same action as the one the system passes to you. You must create your own bar button with an image, because there is no possible way with AppStore approved API to create back bar buttons.
In iOS7, the private subclasses are UINavigationItemView + _UINavigationBarBackIndicatorView. One is the button, the other - the chevron. _UINavigationBarBackIndicatorView is a subclass of UIImageView. So it's pretty close to what you will achieve.
In iOS 8, UISplitViewController has a method:
- (UIBarButtonItem *)displayModeButtonItem
If you set the returned bar button item as the left button of a navigation bar (UINavigationBar), it will display the chevron for you.
On the other hand, if you put the returned bar button item into a toolbar (UIToolbar), it will not display the chevron.
For places where I want the chevron back button shown, but also need several of my own bar button items shown (like the Mail app on iPad does), I have to use a UINavigationBar and a UIToolbar. It's an ugly solution, but I have to partially overlay the UINavigationBar on top of the UIToolbar in order to get a back button chevron along with several of my own bar button items.
To access the default back button image used by Apple as what Leo said, the arrow is a class of type _UINavigationBarBackIndicatorView. Set this image to a back bar button and you are good to go.
Here follows the hack,
UIImage *imgViewBack ;
for (UIView *view in self.navigationController.navigationBar.subviews) {
// The arrow is a class of type _UINavigationBarBackIndicatorView. This is not any of the private methods, so I think
// this is fine for the AppStore...
if ([NSStringFromClass([view class]) isEqualToString:#"_UINavigationBarBackIndicatorView"]) {
// Set the image from the Default BackBtn Imageview
UIImageView *imgView = (UIImageView *) view;
if(imgView){
imgViewBack = imgView.image ;
}
}
}
This is based on Ryan Henning's answer.
It's possible to show a back button representing the master view from the detail view controller. The UISplitview controller doesn't provide a native method for this, but it returns a bar button object which we can directly assign as navigation controller bar button. Its obvious that the detail view controller should be inside a navigation controller for this to work.
self.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;

Resources