首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >单元格分配时如何更改UICollectionReusableView中的按钮UICollectionReusableView

单元格分配时如何更改UICollectionReusableView中的按钮UICollectionReusableView
EN

Stack Overflow用户
提问于 2014-11-18 14:36:35
回答 1查看 217关注 0票数 0

我有一个带有按钮的UICollectionReusableView,当用户点击按钮时,我想要更改backgroundColor和borderColor。BackgroundColor改变了,但borderColor没有改变。

代码:

代码语言:javascript
复制
@implementation ClothesTopView

//==============================================================================

- (void)configCell:(id<ClothesTopViewDelegate>)delegate
{
    _clothesTopViewDelegate = delegate;
    for (UIButton *button in _topButtonCollection)
    {
        button.layer.cornerRadius = 2;
        button.layer.borderWidth = 1.f;
        button.layer.borderColor = [UIColor whiteColor].CGColor;
    }
}

//==============================================================================

- (IBAction)topButtonAction:(UIButton *)sender
{
    for (UIButton *button in _topButtonCollection)
    {
        if (button == sender)
        {
            sender.layer.borderColor = [UIColor colorWithRed:226/255.f green:71/255.f blue:49/255.f alpha:1.f].CGColor;
            sender.backgroundColor = [UIColor colorWithRed:226/255.f green:71/255.f blue:49/255.f alpha:1.f];
        }
        else
        {
            button.layer.borderColor = [UIColor whiteColor].CGColor;
            button.backgroundColor = [UIColor clearColor];
        }
    }
    [_clothesTopViewDelegate topViewButtonDidPressWithTitle:sender.titleLabel.text];
}

//=========================================================================

@end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-05-08 12:31:26

应用更改后,尝试调用此方法

代码语言:javascript
复制
 [self setNeedsDisplay];

这将告诉iOS重新绘制单元格,您的边框颜色应该会改变。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26996838

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档