开发者

Change the width of the cell content

开发者 https://www.devze.com 2022-12-30 05:46 出处:网络
I want to change the width of the cell content. (see the pic) alt text http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/Art/tv_cell_pa开发者_运维百科r

I want to change the width of the cell content. (see the pic) alt text http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/Art/tv_cell_pa开发者_运维百科rts.jpg

My code:

 CGSize contentViewSize = cell.contentView.bounds.size;
    contentViewSize.width = 20.0f;

But there is no effect, what's wrong?

Any suggestion will be appreciated, thanks.


You need to re-assign the frame for the cell's contentView.

CGRect oldFrame = cell.contentView.frame;
cell.contentView.frame = CGRectMake( oldFrame.origin.x,
                                     oldFrame.origin.y, 
                                     oldFrame.size.width + 20, 
                                     oldFrame.size.height );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号