Setting UITableViewCellStyle2 Tint Color - ios7

I can't believe I don't see this anywhere on Google, but I have an odd issue.
I am changing the Global Tint in iOS 7 in the App Delegate:
[[UIView appearance] setTintColor:[UIColor redColor]];
However, when I display a table view with UITableViewCellStyle2 cells, the text title color is still the default blue color.
Any ideas on how I could fix this? I'd rather not subclass it.
Thanks!

simply change the text color.
cell.textLabel.textColor = [UIColor redColor];

Related

Objective-C NSScrollView Foreground Colour

I am getting into app development and just started using NSScrollViews to display large chunks of text.
I am able to set the background colour by writing the following:
[_HeadersScrollView setBackgroundColor:[NSColor darkGrayColor]];
But not set the foreground colour by doing something similar to:
[_HeadersScrollView setTextColor:[NSColor whiteColor]]; // nope
[_HeadersScrollView setForegroundColor:[NSColor whiteColor]]; // nope
[_HeadersScrollView setForeground:[NSColor whiteColor]]; // nope
Is there a method or any other way that I could get this type of setup to work? I'd really appreciate it.
The NSScrollView contains an NSClipView (a helper for scrolling) which contains the NSTextView. If you want to operate on the text view you either need an outlet to that or you can request the documentView from the scroll view.
You can do either:
[_HeadersScrollView.documentView setTextColor:[NSColor whiteColor]];
Or, if you have an outlet to the text view (called _textView in my example), you can do:
_textView.textColor = [NSColor whiteColor];
In this case, you would probably want to set the background color on the text view, too, rather than the scroll view. And tell it to draw its background by setting drawsBackground.
There is no setting like that for changing foreground color in scrollview.
_HeadersScrollView.tintColor = [NSColor whiteColor];
or
[_HeadersScrollView setTintColor:[NSColor whiteColor]];

Background colors in UITableViewController with UISearchbar

please look at the following screenshot.
It shows a UITableviewController with a UISearchdisplayController in the view header. I have set the background color of the table view to a somehow white color (see the below area). However the area above the UISearchbar does not have the same color (gray). How can I set / change this color? I tried different approaches like:
Adding additional subview
Seachbar background color
...
But till now i have had no success. Can anybody help me? Thanks in advance.
So i found the issue:
I was using:
self.tableView.tableViewHeader = self.searchDisplayController.searchbar;
Now I am using an aditional view with the searchbar as subview:
UIView *v = [[UIView alloc] initWithFrame:self.searchDisplayController.searchbar.frame];
[v addSubview:self.searchDisplayController.searchbar];
self.tableView.tableHeaderView = v;
Everything works fine now, the gray color is gone and the backgorundColors are equal.
you can play with
[[UISearchBar appearance] setBarTintColor:[UIColor redColor]];
or
[[UISearchBar appearance] setTintColor:[UIColor greenColor]];

How to set color of UISearchBar to match exactly what we want

I set the same color for the UISearchbar and the area surrounding it. Yet, the color of search bar seems to be dominated by something else.
Doing
self.srchBar.tintColor = [UIColor clColorOfUISearchBar];
self.srchBar.backgroundColor = [UIColor clColorOfUISearchBar];
Doesn't work. Even if I set that to something obvious like red, the red would be well, background. There is something grey on top of it.
There is no UISearchBar foreground color.
So what should I do?
How about:
[searchBar setBackgroundImage:[UIImage new]];
[searchBar setTranslucent:YES];

UITabbar with partially transparent background

Long time reader, first time poster. Please be gentle :P
I'm working on an app and have a background image for a UITabbar element that is transparent for a few pixels at the top. I have searched far and wide, tried many solutions suggested that I could find (setting tint, background color to clearColor, setting alpha to 0.2, etc) but I continue to see a black line where the tabbar should be transparent. I am setting the background as follows (see the lines commented out for some more things I have tried which did not work)
//[[UITabBar appearance] setBackgroundColor:[UIColor clearColor]];
//[self.view setBackgroundColor:[UIColor clearColor]];
//[super.view setBackgroundColor:[UIColor clearColor]];
//UITabBar.super.setBackgroundColor:[UIColor clearColor]];
[[UITabBar appearance] setBackgroundColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.2]];
//[[UITabBar appearance] setTintColor:[UIColor blackColor]];
[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.1]];
//[[UITabBar appearance] setAlpha:0.0];// setTintColor:[UIColor magentaColor]];
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tabbar.png"]];
Screenshot can be fount at http://i.imgur.com/m1tW5.png
The app uses a tabbarcontroller.
When I set the background color to white or any other color, the black line changes color successfully but as soon as I set the color to clearColor the black line comes back.
When I hide the entire tab bar there is nothing crazy behind it and I can successfully see the cream background as I should.
The image is a png with a transparent top where the black line appears as mentioned earlier.
Does anyone have any suggestions on what I could be doing wrong?
Help will be truly appreciated.
Edit: I am using iOS 5.0 and don't care about supporting previous iOS versions (in case that opens up any additional potential choices).
I'm currently trying to solve a similar problem.
I believe the black color is either:
The TabBars Superviews background in which case you can try to set the tabBars superviews background color. I don't have my mac here so I can't try it and I don't see that in your "tried" code.
Or it's the border of the tabBar, in which you can change the bordercolor of the tabBar's frame.
tabbar.frame.borderColor = [UIColor whiteColor];
You will need to import the QuartzCore framework to manipulate the boderColor.
Let me know if it helps.
I decided to go with a "hack-ish" solution I came across elsewhere.
I'm using the same color as the background in areas of the tab bar's background image to create the illusion of transparency. Not really transparent but that's the best I could come up with after countless hours spent on this.
Maybe that'll be a solution that works for someone else in a similar position in the future as well.

UiBarButtonItem Same Color as "Done" Button

I want to be able to programatically add a UIBarButtonItem to a Navigation Bar and set it's tint color to the exact same blue shade as Apple's "Done" UIBarButtonItem.
I am already doing this for Apple's red shade in this block of code:
UIBarButtonItem *myDeleteButton = [[UIBarButtonItem alloc] initWithTitle:#"Clear" style:UIBarButtonItemStyleBordered target:self action:#selector(myDeleteItemsMethod:)];
myDeleteButton.tintcolor = [[UIColor alloc] initwithRed:1 green:0.0470275 blue:0.0116515 alpha:1];
self.navigationItem.rightBarButtonItem = myDeleteButton;
I guess all I need are the RGB values.
I'm having a hard time trying to "reverse engineer" a UIBarButtonItem's tint that was made in Storyboard (Can't cast UIColor as text).
And I also realize that Xcode's color palette has an area for "developer" color schemes but it does not appear to include the color for the "Done" button.
I spent about 15 mins with my DigitalColor Meter and basically guessed and checked until I finally got it. The problem is that you're adding a "tint" to a black button to make it blue, so it won't be the right blue. Here's the correct measurements:
[buttonName setTintColor:[UIColor colorWithRed:34.0/255.0 green:97.0/255.0 blue:221.0/255.0 alpha:1]];
Hope it helps someone :)
You want UIBarButtonItemStyleDone rather than UIBarButtonItemStyleBordered.
The proposed color of user1641653 is just the bottom color of the real DoneButton taken with the color meter. The problem is that the shadow of a plain/borderer button is different than the one of a SystemButton. The shadow will change the proposed color by -11, -36, -11.
So if you really want it to look like the real DoneButton you have to add those values to the proposed 34/97/221.
This means:
[yourButton setTintColor:[UIColor colorWithRed:45.0/255.0 green:133.0/255.0 blue:232.0/255.0 alpha:1]];