mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Fix cell selection and highlighting in ASCollectionView
This commit is contained in:
49
examples/ASCollectionView/Sample/ItemNode.m
Normal file
49
examples/ASCollectionView/Sample/ItemNode.m
Normal file
@@ -0,0 +1,49 @@
|
||||
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||
* purposes only. Facebook reserves all rights not expressly granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import "ItemNode.h"
|
||||
|
||||
@implementation ItemNode
|
||||
|
||||
- (instancetype)initWithString:(NSString *)string
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
self.text = string;
|
||||
[self updateBackgroundColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateBackgroundColor
|
||||
{
|
||||
if (self.highlighted) {
|
||||
self.backgroundColor = [UIColor grayColor];
|
||||
} else if (self.selected) {
|
||||
self.backgroundColor = [UIColor darkGrayColor];
|
||||
} else {
|
||||
self.backgroundColor = [UIColor lightGrayColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected
|
||||
{
|
||||
[super setSelected:selected];
|
||||
[self updateBackgroundColor];
|
||||
}
|
||||
|
||||
- (void)setHighlighted:(BOOL)highlighted
|
||||
{
|
||||
[super setHighlighted:highlighted];
|
||||
[self updateBackgroundColor];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user