1016-06-homepage 20-encapsulation toolbar --- distance between UITableView control and top ---- background color settings when cell is selected, and toolbar on top of android

Source: Internet
Author: User

1016-06-homepage 20-encapsulation toolbar --- distance between UITableView control and top ---- background color settings when cell is selected, and toolbar on top of android

1. Set the spacing between the cell on the top and the cell on the top of the UITableView:

Method 1. directly set: self. tableView. contentInset = UIEdgeInsetsMake (HWStatusCellMargin, 0, 0, 0 );

@ Interface HWHomeViewController: UITableViewController
@ End


@ Implementation HWHomeViewController

-(Void) viewDidLoad
{
[Super viewDidLoad];

Self. tableView. contentInset = UIEdgeInsetsMake (15, 0, 0, 0 );

}

@ End

 

Method 2. Rewrite setFrame in cell:

-(Void) setFrame :( CGRect) frame
{
Frame. origin. y + = 15;
[Super setFrame: frame];
}

 

Method 3. Add the y value of the sub-control in each microblog (each cell) to 15

 

 

Ii. Background color settings when cell is selected:
-(Void) tableView :( UITableView *) tableView didSelectRowAtIndexPath :( NSIndexPath *) indexPath
{

// Set the selected background to blue
// UIView * bg = [[UIView alloc] init];
// Bg. backgroundColor = [UIColor blueColor];
// Self. selectedBackgroundView = bg;

// This method is not feasible.
// Self. selectedBackgroundView. backgroundColor = [UIColor blueColor];

// HWLog (@ "didSelectRowAtIndexPath --- % @", NSStringFromUIEdgeInsets (self. tableView. contentInset ));
}

Related Article

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.