objective c - iOS UITableView selection hides subview button background color -


I have a button in the form of subserves of the table view cell, I want a table view to show selection when tape The color of selection overrides the background color in the color button. For example, if I have a red background button with a title, then the title is only one thing on the selection, the color will not appear as a color only selection color. When the selection is over, I can see the button again, but is there any way to override this behavior?

Try this: - (UITableViewCell *) Table View: ( UITableView *) Table View CellForAind Pound: (NSIndexPath *) Index Path {Fixed NSString * CellIdentifier = @ "CountryCell"; UITableViewCell * cell = [tableview] dequeueReusableCellWithIdentifier: CellIdentifier]; Cell = zero; If (cell == blue) {cell = [[[UTTViewjell Alok] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cell identifier] AutoExes]; } [UIColor clearColor]; Cell.selectionStyle = UITableViewCellSelectionStyleGray; // This is the code that fixes the problem CAGradientLayer * gr = [CagradientLayer layer]; Gr.frame = cell frame; Gr.colors = [NSArray arrayWithObjects: (ID) [[UIColor colorWithRed: 0 green: 0 blue: 0 alpha: .0] CGColor], (id) [[UIColor colorWithRed: 0 green: 0 blue: 0 alpha: .0 ] CGColor], zero]; Gr.locations = [NSArray arrayWithObjects: [Flowweight with NSNumber number: 0], [NSNumber number: 1], zero]; [Cell. Insert Layer, Square: Index on Gr: 0]; // your button UI button * btn = [[UIButton alloc] init]; BTN = [UIButtonTypeCustom] with UIButton Button; BTN.frame = CGRactam (10, 5, 100, 20); [BTN SETTITAL: @ State for "Testing": UICOnlineStartNational]; [BTN setbackground image: [UIImage imageNamed: @ "headerimg.png"] forState: UIControlStateNormal]; [Cell.contentView addSubview: BTN]; Return cell; } Note: You need to use the desired background color image. Do not set the background color of the button.

It has already been tested & amp; Work solution

Hope this will help you.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -