CODER_DJ Custom Tableviewcell Slip Delete button

Source: Internet
Author: User

turn from: http://www.cnblogs.com/Coder-DJ/p/5645392.html


-(void) layoutsubviews

{

[Super Layoutsubviews];

For (UIView *subview in Self.subviews)

{

if ([Subview iskindofclass:nsclassfromstring (@ "Uitableviewcelldeleteconfirmationview")])

{

UIView *confirmview= (UIView *) [subview.subviews firstobject];

Change background color

Confirmview.backgroundcolor=[uicolor colorwithwhite:0.898 alpha:1.000];

For (UIView *sub in Confirmview.subviews)

{

Modify the size and color of the word to modify the text style

/*

if ([Sub Iskindofclass:nsclassfromstring (@ "Uibuttonlabel")]) {

Uilabel *deletelabel= (Uilabel *) Sub;

Deletelabel.backgroundcolor = [Uicolor Redcolor];

Change the font size of the delete button

Deletelabel.font=[uifont BOLDSYSTEMFONTOFSIZE:20];

Change the text of a button

deletelabel.text=@ "hehe";

}

*/

Add a picture

if ([Sub Iskindofclass:nsclassfromstring (@ "UIView")]) {

UIView *deleteview = Sub;

Uiimageview *imageview = [[Uiimageview alloc] init];

Imageview.image = [UIImage imagenamed:@ "Iconfont-zhuchang"];

Imageview.frame = CGRectMake (Cgrectgetmaxx (sub.frame)-58,-5, 30, 30);

[Deleteview Addsubview:imageview];

}

}

Break

}

}

}

So you can successfully modify the Delete button of the red background color into a custom picture.

But careful little partner will find that every time you click on the button button will appear a short white delete text, do not be afraid, let us rewrite a method is good:

#pragma mark Change Delete button text (make text blank)

-(nsstring*) TableView: (uitableview*) TableView Titlefordeleteconfirmationbuttonforrowatindexpath: (NSIndexPath*) Indexpath {

return @ "";

}

That's the solution.

Sometimes there is also a requirement for sideslip to display two options, which is also very simple, in-(Nsarray *) TableView: (UITableView *) TableView Editactionsforrowatindexpath: ( Nsindexpath *) Indexpath method to add uitableviewrowaction on the line, the specific people to grope themselves out.

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.