2012-09-25 133 views
1

我使用的GMGridView與子類型UIView作爲contentView的單元格。這些在GMGridView的單元格突出顯示

- (GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index 

分配現在,我想的細胞有一大亮點,類似於UIButton的行爲。這意味着有一個稍微不透明的較暗覆蓋層。我只是無法弄清楚我不得不分配突出顯示的位置。

我看到GMGridViewCell有一個名爲highlighted的屬性,它指示該單元格是否突出顯示。在上述方法中將其設置爲cell.highlighted = YES;不會改變單元格外觀的任何內容。

GMGridView網站上的描述,它說

特點 - 一般:

  • 細胞高亮的支持

所以,應該有一種方法...

有人可以告訴我,如何突出顯示應分配?

回答

1

我討厭它發生這種情況。剛剛找到答案。

顯然突出顯示將應用於cell.contentView的子視圖,這裏可以看到in the commit

將被設置在電池突出而感動:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    self.highlighted = YES; 
} 

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    self.highlighted = NO; 
} 

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    self.highlighted = NO; 
} 

然後子視圖高亮度狀態將被激活。

-(void)setHighlighted:(BOOL)aHighlighted { 
    highlighted = aHighlighted; 

    [self.contentView recursiveEnumerateSubviewsUsingBlock:^(UIView *view, BOOL *stop) { 
     if ([view respondsToSelector:@selector(setHighlighted:)]) { 
      [(UIControl*)view setHighlighted:highlighted]; 
     } 
    }]; 
} 

因此,實現單元格高亮,我不得不與我的自定義單元格鑑於部分上面的透明層添加UIImageView。希望這有助於任何人。

相關問題