【问题标题】:UITableViewCell with rectangular corners in grouped style具有分组样式的矩形角的 UITableViewCell
【发布时间】:2012-06-07 16:28:04
【问题描述】:

我想在我的单元格上设置矩形角。 我实现了

     cell.backgroundView = [[UIView alloc] initWithFrame:cell.bounds];

正如this comment 中所建议的那样,但是当我点击单元格时,高光仍然是圆角...我怎样才能摆脱这些?

【问题讨论】:

    标签: objective-c ios uitableview


    【解决方案1】:
    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.bounds];
    

    【讨论】:

    • 谢谢,看起来不错 - 你知道高光的颜色是什么吗?它比蓝色更轻...
    【解决方案2】:

    ...为了模仿亮点,你应该有

        #import <QuartzCore/QuartzCore.h>
    
        CAGradientLayer *gradient = [CAGradientLayer layer];
        gradient.frame = cell.bounds;
        gradient.colors = [NSArray arrayWithObjects:[[UIColor colorWithRed:0. green:0.545 blue:0.941 alpha:1] CGColor], [[UIColor colorWithRed:0.027 green:0.353 blue:0.878 alpha:1] CGColor], nil];
        [cell.selectedBackgroundView.layer insertSublayer:gradient atIndex:0];
    

    它并不完美 - 仍在检查为什么它以纵向绘制越过单元格的右边界,并且在我旋转设备时不横向缩放...

    欢迎提出建议。

    【讨论】:

    • 您是否尝试过将自动调整大小的蒙版设置为灵活的高度和宽度?
    猜你喜欢
    • 2011-12-03
    • 1970-01-01
    • 1970-01-01
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多