Ios-tableview Setting rounded corners

Source: Internet
Author: User


Set the fillet setting for the TableView overall

Set rounded corners
V_tableview.layer.cornerRadius = 7;
V_tableview.layer.masksToBounds = YES;
Set border
V_tableview.layer.borderWidth = 1;
V_tableview.layer.borderColor = [COLOR (189, 189, 189, 1) Cgcolor];

IOS7 settings for each set of rounded corners after grouping

#pragma mark-table View data source
-(void) TableView: (UITableView *) TableView Willdisplaycell: (UITableViewCell *) cell Forrowatindexpath: (Nsindexpath *) indexpath{
//
if ([Cell respondstoselector: @selector (Tintcolor)]) {
if (TableView = = V_tableview) {
//
CGFloat Cornerradius = 10.f;
Cell.backgroundcolor = Uicolor.clearcolor;
Cashapelayer *layer = [[Cashapelayer alloc] init];
Cgmutablepathref pathref = cgpathcreatemutable ();
CGRect bounds = cgrectinset (cell.bounds, 0, 0);
//
BOOL addline = NO;
Draw rounded Corners
if (Indexpath.row = = 0 && Indexpath.row = = [TableView numberofrowsinsection:indexpath.section]-1) {
//
Cgpathaddroundedrect (pathref, nil, bounds, Cornerradius, Cornerradius);
//
} else if (Indexpath.row = = 0) {
//
Cgpathmovetopoint (Pathref, Nil, cgrectgetminx (bounds), cgrectgetmaxy (bounds));
//
Cgpathaddarctopoint (Pathref, Nil, cgrectgetminx (bounds), cgrectgetminy (bounds), cgrectgetmidx (bounds), C Grectgetminy (bounds), Cornerradius);
//
Cgpathaddarctopoint (Pathref, Nil, cgrectgetmaxx (bounds), cgrectgetminy (bounds), Cgrectgetmaxx (bounds), C Grectgetmidy (bounds), Cornerradius);
//
Cgpathaddlinetopoint (Pathref, Nil, cgrectgetmaxx (bounds), cgrectgetmaxy (bounds));
//
AddLine = YES;
//
} else if (Indexpath.row = = [TableView numberofrowsinsection:indexpath.section]-1) {
//
Cgpathmovetopoint (Pathref, Nil, cgrectgetminx (bounds), cgrectgetminy (bounds));
//
Cgpathaddarctopoint (Pathref, Nil, cgrectgetminx (bounds), cgrectgetmaxy (bounds), cgrectgetmidx (bounds), C Grectgetmaxy (bounds), Cornerradius);
//
Cgpathaddarctopoint (Pathref, Nil, cgrectgetmaxx (bounds), cgrectgetmaxy (bounds), Cgrectgetmaxx (bounds), C Grectgetmidy (bounds), Cornerradius);
//
Cgpathaddlinetopoint (Pathref, Nil, cgrectgetmaxx (bounds), cgrectgetminy (bounds));
//
} else {
//
Cgpathaddrect (pathref, nil, bounds);
//
AddLine = YES;
//
//            }
//
Layer.path = Pathref;
//
Cfrelease (PATHREF);
//
Layer.fillcolor = [Uicolor colorwithwhite:1.f alpha:0.8f]. Cgcolor;
//
//
//
if (AddLine = = YES) {
//
Calayer *linelayer = [[Calayer alloc] init];
//
CGFloat lineheight = (1.F/[UIScreen Mainscreen].scale);
//
Linelayer.frame = CGRectMake (Cgrectgetminx (bounds) +10, Bounds.size.height-lineheight, bounds.size.width- Ten, lineheight);
//
Linelayer.backgroundcolor = TableView.separatorColor.CGColor;
//
[Layer Addsublayer:linelayer];
//
//            }
//
UIView *testview = [[UIView alloc] initwithframe:bounds];
[Testview.layer Insertsublayer:layer atindex:0];
Testview.backgroundcolor = Uicolor.clearcolor;
Cell.backgroundview = TestView;
//
//        }
//
//    }
//
//}

TableView the selected color settings

    1. //Colorless   
    2. Cell.selectionstyle = Uitableviewcellselectionstylenone;
    3. //Blue    
    4. Cell.selectionstyle = Uitableviewcellselectionstyleblue;
    5. //Grey    
    6. cell.selection style = uitableviewcellselectionstylegray; 

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.