I have a project that comes from IOS6, and now with the button changes of the IOS7 I had to make a background to my project buttons. Although, when I try to set a background image for my buttons it doesn't work! programming or not it doesn't work!
I tryied:
[buttonOutlet setBackgroundImage:[UIImage imageNamed:#"lineStyleScreen.png"] forState:UIControlStateNormal];
and the IDE! BOTH DONT WORK!!!
I wonder if it is because I did't updated my storyboard to IOS7.
ios 7 doesnt support regular ios 6 buttons. Do follow this link:
http://dev.iachieved.it/iachievedit/?p=127
Is the button type set to Custom in properties inspector?
Try to set the tint color to the button for iOS 7
button.tintColor = [UIColor greenColor];
Note:- set the tint color that will suit to your requirement
Related
I've spent a whole day trying to change the colour of a UIBarButtonItem and now i'm thinking it is an iOS 11 bug unless someone can tell me it's by design.
I can change the colour of the text by using this code
[self.refreshButton setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateNormal];
If I add the code to the viewWillAppear:animated function it works fine, however if you add it to viewDidAppear:animated it does not work.
It seems to work on the iOS 9 simulator, but not iOS 11.
Has something changed in this regard in iOS 11?
If all you want to do is change the title color of your UIBarButtonItem you can set the tintColor property instead of setTitleTextAttributes:. If you want all of your UIBarButtonItems to have the same title color you can set the tintColor of your tool/navigation bar.
I had the same issue on iOS11 but needed to set the font by setTitleTextAttributes. Unfortunately this does also not work by appearance. The only solution I found was to create new BarButtonItems as copy of the old ones and then set them as navigationItem.rightBarButtonItems.
For reference for other users having the same issue.
This Stack Overflow answer may explain why the method doesn't work.
An improper setting of UIControlState() may be the problem.
I'm using Xcode 6.1.1
Is it possible to set the background colour in code for the selected/highlighted state for UIButton? - Not a background image!
I'm using ID's for colors (e.g. #"theme.brand.primary") that are linked to a json file i.e. .plist file
I've done it for setTitleColor UIControlStateHighlighted which works fine... example code:
[button setTitleColor:[config getColour:#"button.text.pressed-state"] forState:UIControlStateHighlighted];
However I want the colour of the button to change not the title.
There is no option for setBackgroundColor:forState: ???
Does anyone know if theres a simple way to do this?
Can you not just check for highlighted?
if (myButton.highlighted) {
myButton setBackgroundColor.......
}
I have open-sourced a class, STAButton, to fill this functionality hole. Available under the MIT license. Works for iOS 7+ (I have not tested with older iOS versions).
I need a code that removes this default background, in IOS 7 there isn't a problem since I don't see this background.
If you choose a button of type UIButtonTypeCustom, there will be no default background
Try this,
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeCustom];
In iOS 7 default UIButton is like hyperlink in web page, with transparent background and no boarders. iOS 7 is actually border less now, If you want to have corners and backgrounds like iOS 6 use custom button. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom] Now you can set background and other things if you want.
I am using the below code to get a shadow to button title label.
theCuLabel.titleLabel.shadowColor=[UIColor blackColor];
theCuLabel.titleLabel.shadowOffset=CGSizeMake(-3.0,2.5);
In IOS 6 its working properly like below
But in IOS 7 its not working as expected like below
I didn't find solution for this, can any one tell me the solution or any update in IOS 7 that happened for this.
Thanks in Advance...
[button setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal];
this is the correct method to set the shadow color for a UIButton.
I have tried this and is working in all versions.
I have some weird trouble about iOS 7. I have an UINavigationBar in my app and it works perfect for iOS 6;
-- IOS 6 --
However, when i try to run it on iOS 7, my back button disappeared. It's there, still working and clickable but not visible;
-- IOS 7 --
How can I fix this problem ?
Setting BackButtonBackgroundImage via UIAppearance currently has some odd behavior in iOS 7. This is probably related to the updated design, which replaces the rect-style button with a backIndicatorImage (an arrow).
This leaves 3 options for customizing the back button's appearance:
Change the color of the backIndicatorImage by setting the tintColor property on UINavigationBar (or one of its superclasses).
Set the new backIndicatorImage property on UINavigationBar to a custom image. (don't forget to set the backIndicatorTransitionMaskImage as well or it won't work)
Create a custom UIBarButtonItem and manually assign it as UINavigationItem's leftBarButtonItem. (See the answer mentioned above by Mashhadi)
By the way, if you have to keep support ios 6 version like me, use that;
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1)
{
// My iOS 6 back button background
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:39.0f/255.0f green:184.0f/255.0f blue:199.0f/255.0f alpha:1.0];
}
else
{
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
I used Wes Dearborn's answer and implemented a nice way of supporting both iOS5+'s back button and iOS7's backIndicatorImage:
Back button strangely disappearing in UINavigationController but keeps working