Ios-tableviewcell the background color disappears when selected.

Source: Internet
Author: User

Add a child control on the cell, when we click or long press, if the child control has a background color, the background color will be gone, this time the product manager came to a meal godless,??。 Just think of the following diagram:

So if you want to do a long press or click on the background color is not rendered, very simple, in the custom cell when the time to write two methods:

-(void) setselected: (BOOL) selected animated: (bool) animated {    [Super setselected:selected animated:animated];    [Self changcolor];    Configure The view for the selected state}-(void) sethighlighted: (BOOL) highlighted animated: (BOOL) animated{    [ Super sethighlighted:highlighted animated:animated];    [Self changcolor];} -(void) changcolor{    //This is where the child controls initialize what color to set.    Self.label.backgroundColor = [Uicolor orangecolor];        Background color of other child controls}

Look at the effect:

Ios-tableviewcell the background color disappears when selected.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.