how to add colour in verticalSeprator UITable - ios

How i can add specific colour in verticalSeperator UITable.I tried with UIColor option but its not working please help me to solve this.
HJTextFieldCell *cell = (HJTextFieldCell *)[_tableView dequeueReusableCellWithIdentifier:textCellIdentifier];
cell.constraint_leftSideOftxtFild.constant = 10.0f;
cell.constraint_heigntOfTxtField.constant = 30.0f;
cell.lbl_verticalSeprator.hidden =NO;
cell.lbl_verticalSeprator.textColor = [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.098/255.0 alpha:0.22];

Try with background color not text color.
cell.lbl_verticalSeprator.backgroundColor = [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.098/255.0 alpha:0.22];
and the best way is to use native separator and you can change the color with tableView.separatorColor of UITableview

Related

background for uitableview cell

MyTableCell *cell=[[MyTableCell alloc]init];
cell.backgroundColor = [UIColor clearColor];
The above lines of code are still showing the white color of the cell's background and hiding the background image of the tableview.
Go to you storyboard and set the color of your uitableview cell to clear color from there.And also set uitabelview color also to clear color.
Or in you viewdidload set tableview background color to clear color and in cellforrow at indexparth delagate set
cell.contentView.backGroundColor = [UIColor ClearColor]
try this
- (void)tableView:(UITableView *)tableView willDisplayCell(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setBackgroundColor:[UIColor clearColor]];
}
set the contentview background color also
cell.contentView.backGroundColor = [UIColor ClearColor];
cell.backGroundView.backGroundColor = [UIColor ClearColor];
cell.selectedBackGroundView.backGroundColor = [UIColor ClearColor];
Also check if you cleared the tableView.backGroundColor also
Thank you every one. I have solved the problem. I changed the background attribute in the attribute inspector in the storyboard for my cell object from default to clear color and it worked.
You can do it this way
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];

UITableView weird separator line color

i have a problem in setting UITableViewCell background color. I wanna change it into my own color, so I use this code to change that background color :
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [ColorManager backgroundInput];
bg.layer.masksToBounds = YES;
[cell setSelectedBackgroundView:bg];
I implement this code in CellForRowAtIndexPath method.
The weird thing I have is, when i tap into a cell, the separator line color being highlight just like the image below. I just wanna make it still dark, anybody have idea?
Thank you
After setting up your own background view,which will have the line or not,
you can clear the default tableview color
tablename.separatorColor = [UIColor clearColor];
OR
If you don't want to remove the default line then you can give same color of background view to line color
//You can specify the RGB of background view
tablename.separatorColor = [UIColor colorWithRed:R green:G blue:B alpha:1.0f];
I think the best option is
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
Another option is to set the backgroundColor of the UITableViewCell to a clear color.
cell.backgroundColor = [UIColor clearColor];
try it
Objective-c
tablename.separatorColor = [UIColor blackColor];
Swift
tablename.separatorColor = UIColor.blackColor();

Colour changed in iOS7.1, how to change searchBar colour?

On iOS7.0.3 - 7.0.6, my searchBar colour is Gold/yellow colour like this:
But on iOS 7.1, colour becomes like this:
I set
searchBar.tintColor = [UIColor clearColor];
searchBar.backgroundColor = goldColor;
searchBar.tintColor = [UIColor blackColor];
I've tried so many ways and all are failed. Can anyone figure out what changes in iOS 7.1?
============== My fix ===============
I fix this problem by covering a view on searchBar and add the search text filed as subview on this new view.
I need point out that the gold status bar is a subView of searchBar, and it's frame is CGRectMake(0, -20, 320, 20) and it's background colour is gold.
At first, I set this:
_searchBar.translucent = YES;
_searchBar.scopeBarBackgroundImage = [self imageWithColor:UWGold];
and looks like this:
Then, I expand the view cover the status bar, I changed the view's frame.size.height + searchBar's height, then use this line:
UITextField *textSearchField = [_searchBar valueForKey:#"_searchField"];
to get the textSearchField, then add this textSearchField to the cover view.
At last, the searchBar is exactly like when on iOS 7.0
Not a good way, I need figure out what changes on iOS 7.1 and use a right way to implement this.
Try this:
if(IOS_7)
{
self.searchBar.searchBarStyle = UISearchBarStyleMinimal;
self.searchBar.backgroundImage = [UIImage imageWithColor:[UIColor redColor] cornerRadius:5.0f];
}
Hopefully this will help you.
None of the above answers worked for me on iOS 7/8. Here's some setup code that did the trick:
searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
searchBar.scopeButtonTitles = #[#"Scope1", #"Scope2"];
searchBar.selectedScopeButtonIndex = 0;
searchBar.backgroundColor = [UIColor clearColor];
searchBar.barTintColor = [UIColor clearColor];
searchBar.translucent = YES; // SUPER IMPORTANT, REMOVING THIS MESSED UP THE SCOPE BAR
// ONLY USE IMAGES, NOT BACKGROUND COLORS
UIImage *searchBarBackgroundImage = [[UIImage imageNamed:#"SearchBarBackgroundImage"];
UIImage *scopeBarBackgroundImage = [[UIImage imageNamed:#"ScopeBarBackgroundImage"];
[searchBar setBackgroundImage:searchBarBackgroundImage
forBarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
searchBar.scopeBarBackgroundImage = scopeBarBackgroundImage;
searchBar.tintColor = [UIColor whiteColor];
I used next approach for changing backgroundColor of searchBar
1.As suggested by #Ben Jackson - set BackgroundImage
[self.searchBar setBackgroundImage:[self imageWithColor:[UIColor blueColor]] forBarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
2.Change textField to what u need according to design
NSArray *searchBarSubViews = [[self.searchBar.subviews objectAtIndex:0] subviews];
for( int i = 0; i < searchBarSubViews.count; i++) {
if([[searchBarSubViews objectAtIndex:i] isKindOfClass:[UITextField class]]) {
UITextField *searchTextField = (UITextField *)[searchBarSubViews objectAtIndex:i];
[searchTextField setTintColor:[UIColor blueColor]];
searchTextField.placeholder = #"Search";
searchTextField.backgroundColor = [UIColor whiteColor];
searchTextField.layer.borderColor = [UIColor blueColor].CGColor;
searchTextField.layer.borderWidth = 1.0f;
searchTextField.layer.cornerRadius = 8.0f;
searchTextField.leftViewMode = UITextFieldViewModeNever;
}
}
Also method for image from color - here
Result:

Setting UITableView backgroundColor in universal app (iOS 5)

I have to set the backgroundColor property of a UITableView to a certain color in my universal app. If I write this...
self.tableView.backgroundColor = [UIColor colorWithRed:146.0f green:197.0f blue:240.0f alpha:1.0f];
...it doesn't work on iPhone nor iPad (background results white).
If I use a standard color, instead...
self.tableView.backgroundColor = [UIColor greenColor];
...it works on iPhone but not on iPad.
I tried other solutions suggested on SO (backgroundView to nil/clearColor, etc.), but none of those works on iOS SDK 5. Can you help me?
You need to divide each color value to 255.
Your color will be:
[UIColor colorWithRed:146/255.0 green:197/255.0 blue:240/255.0 alpha:1.0];
Instead of changing the background color, you can set a backgroundView (with the background color that you like) for the tableView.
UIView *bgView = [[UIView alloc] initWithFrame:self.tableView.bounds];
bgView.backgroundColor = [UIColor redColor];
self.tableView.backgroundView = bgView;
Are you using a navigation controller?
Try this:
self.tableView.backgroundColor = [UIColor clearColor];
[self.tableView setSeparatorColor:[UIColor clearColor]];
self.navigationController.view.backgroundColor = [UIColor greenColor];
Thats what I use with iOS5 and an universal app.

UItableview cell background color

Hey guys i want to make the background of my cell color to be like this
.check the attached image.
thanks
u have to use gradients to get this look.take a look at this tutorial (gradients part) http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients
INSIDE cellforrowind.... function
cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor lightGrayColor];
or
[UIColor colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha];
change those value with red ,green blue ,alpha

Resources