使用自定义选择颜色和边框创建分组的UITableviewCell [英] Create grouped UITableviewCell with custom selection Color and Border

查看:94
本文介绍了使用自定义选择颜色和边框创建分组的UITableviewCell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个应用程序,它在分组表视图中使用不同的选择颜色。就边界来说,这很有效。
我可以使用此帖子中的代码更改选择颜色:
如何自定义背景/边框分组表格视图单元格的颜色?

I'm currently writing an App which uses different selection Colors in a grouped Table View. This works great as far as it comes to Borders. I'm able to change Selection Color with the Code in this Post: How to customize the background/border colors of a grouped table view cell?

但是我还想在Apple附近拥有漂亮的边框使用。我该如何使用此边框?

BUT I'd like to additionally have the nice Border around the Cells that Apple uses. How can I use this Border?

http:/ /www.mediafire.com/?x2gxbkjqu4d2zto

这是创建背景的代码 - 大多是从上面复制的帖子:
http://www.mediafire.com/?kltwlni1mf4t7ks

This is the Code to create the Background - mostly copied from above Post: http://www.mediafire.com/?kltwlni1mf4t7ks

这就是我使用它的方式:

And this is how I use it:

NSIndexPath * indexPath = [[[NSIndexPath alloc] initWithIndex:0] indexPathByAddingIndex:1];
CGRect frame = [[self tableView] rectForRowAtIndexPath:indexPath];
TLCustomCellBackgroundView * selectedBackgroundView = [[TLCustomCellBackgroundView alloc] initWithFrame:frame andColor:[UIColor redColor]];
[selectedBackgroundView setPosition:CustomCellBackgroundViewPositionBottom];
[[[self tableView] cellForRowAtIndexPath:indexPath] setSelectedBackgroundView:selectedBackgroundView];

正如你所看到的,除了第二个Cell周围的灰色边框外,我几乎能正常工作。

As you can see I nearly got it working correctly except of the gray Border around the second Cell.

推荐答案

我找到了一个解决方案。它并不完全相同(因为分组样式中的UITableviewCell在iOS5中得到了更复杂的设计,但这对我来说已经足够了。我从
借用了这个方法 http://cocoawithlove.com/2010/12/uitableview-construction-drawing-and.html

I found a Solution to this. it is not totally the same (as UITableviewCell in grouped Style got a even more sophisticated Design in iOS5 but this is sufficient to me. I borrowed this Approach from http://cocoawithlove.com/2010/12/uitableview-construction-drawing-and.html

并且效果很好!

我使用的代码是: http://www.mediafire.com/?mdxkpfe8g74ctk9

希望这有助于其他人

这篇关于使用自定义选择颜色和边框创建分组的UITableviewCell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆