Changing color of UITableViewCellAccessoryCheckmark and UITextField - iphone

I want to change the color of UITableViewCellAccessoryCheckmark and UITextField background color where we type. I found this is not straight forward.

I solved this issue by changing the tint color of the UITableView where the cell belongs.
Update the Tint Color of UITableView in interface builder to Default
or programmatically as below.
For Objective C
yourTableView.tintColor = [UIColor blackColor];
For Swift
yourTableView.tintColor = .black

By default,you cannot change the color of UITableViewCellAccessoryCheckmark
But alternatively you can use the image for this..as just like checkmark
while for textField you can use this single line..
[textField setBackgroundColor:[UIColor redColor]];

Related

Swift, Custom Cell color Doesn’t Apply behind disclosure indicator

I can't apply same background color in disclosure indicator as same as content view background color.
I have done: propertyCell.selectionStyle = UITableViewCellSelectionStyle. None;
Have tried with the Custom cell background color same as content view color.
Attaching image for the reference of Custome cell's paramers.
Thanks in advance for teh help.
Try to set backgroundColor of UITableViewCell.
propertyCell.backgroundColor = [UIColor redColor]; // your favorite color.
In swift:
cell.backgroundColor = UIColor.back

how can i change ios table group border?

I want to get rid of this white border or colorize it to black.
As you see on the image, i want to change the white borders those shown in red circles.
How can i change it?
after adding this cote to tableview controller's viewDidLoad method;
[self.tuzukCell.contentView.layer setBorderColor:[UIColor blackColor].CGColor];
[self.tuzukCell.contentView.layer setBorderWidth:2.0f];
the resulting border is:
for static cell.. all of these methods .. must be setup in the storyboard file..
so..
click on storyboard file / Table view / Separator "none" / and choose desired color..
UITableViewCell contentView's underlying CALayer
Firstly import QuartzCore
#import <QuartzCore/QuartzCore.h>
Add this in cellForRowAtIndexPath in UITableView delegate method
[cell.contentView.layer setBorderColor:[UIColor blackColor].CGColor]; //any color u want to....
[cell.contentView.layer setBorderWidth:2.0f]; //set its width here
EDIT :Use this property according to requirement if tableview is static:
separatorStyle property
separatorColor property
backgroundView property
In CellForRowAtIndexPath, try this (after you init your cell) :
cell.layer.borderColor = [UIColor blackColor].CGColor;
Of course you can change blackColor to any other UIColor.
You can also do :
cell.layer.borderWidth = 0;
If you just wan to hide it.
the following code will change the separator color, which means that it will change the separator line between the cell and the border itself.
try this to change it to black:
tableView.separatorColor = [UIColor blackColor];
or to remove it:
tableView.separatorColor = [UIColor clearColor];

Setting background color distort the Table cell

I have a grouped table view on one of my view. And inside the cellForRowAtIndexPath delegator method I have set background color for each table cell as follows.
UIColor *color = [UIColor colorWithRed:221.0/255 green:241.0/255 blue:249.0/255 alpha:1.0];
[cell.contentView setBackgroundColor:color];
Background color set without any problem. But problem occur in top and bottom cells. In top and bottom cells have curved edges. But when I add the background color it distort the edges. I have uploaded a print screen in such window.You can see the issue occure in the bottom cell where i have set the background color. Can some one please tell me how to solve this problem.
Use cell.backgroundColor = [UIColor redColor];
not
[cell.contentView setBackgroundColor:color];
A UITableViewCell is a more complex object than an object with a contentView propretry.
You can find more about cell in UITableViewCell Class Reference
Set the cell's clipsToBounds property to YES, that should make it respect rounded cell boundaries.

iPhone: How to change font color in UITableViewCell when selected?

I have a UITableViewCell with labels inside my contentview. When I set the cell selection style to gray or blue, I want the font color in the label to be white. How can I do that?
Use
cell.textLabel.highlightedTextColor = [UIColor whiteColor];
This can also be done directly in Interface Builder. Just select the cell's title or subtitle label, flip to the Attributes inspector, and select the color with this control:
override the method -(void)setselected:(Bool)flag method. change the font

How do I fill the background color of a UITableViewCell?

How do I fill the background color of a UITableViewCell? I tried this code but it didn't work.
cell.backgroundColor = [UIColor redColor];
Try setting a backgroundView for UITableViewCell :
UIView *bgView = [[UIView alloc] init];
bgView.backgroundColor = [UIColor redColor];
cell.backgroundView = bgView;
// release object
[bgView release];
You can change the selection background view of UITableViewCell the same way.
cell.selectedBackgroundView = bgView;
Setting the background color though UITableViewCell's backgroundColor property only works in a Grouped table view. So if your table view is in the Plain style then it won't work.
You can of course set the background color of the UITableView's contentView. But then you probably have to do some additional work as the other subview (text labels and accessory views) have their own idea of background colors.
Take a look at the following snippet from the UITableViewCell documentation.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html
Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.
That should solve your problem.