Tag: filter

在UICollectionView中search和过滤单元格

我有一个单元格的UICollectionView ,所以有两件事情我想用这个视图来完成。 首先,我想在顶部有一个search栏,可以根据用户的查询过滤单元格。 我只看到用UITableView实现的search栏,那么我该怎么做呢? 此外,我想有一个名为“filter”的button,单击时,将显示一个popup式视图控制器与一系列checkbox及其值。 因此,如果我用户select了checkbox,则一旦用户按下位于右上angular的“完成”button,它将根据他们的检查过滤单元。 如果用户不决定过滤他的search,那么左上angular也会有一个“取消”button。 我的UICollectionView的图片: 我的代码 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"Cell"; backpackIcons *item = _backpackItems[indexPath.row]; NSString *photoURL = item.image_url; NSString *quality = item.quality; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; UIImageView *itemImageView = (UIImageView *)[cell viewWithTag:100]; itemImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:photoURL]]]; [itemImageView setBackgroundColor:Rgb2UIColor(60, 53, 46)]; if([[NSString […]

iOS:将RGB滤镜应用于灰度PNG

我有一个灰度的gem顶视图。 (PNG格式,所以有alpha组件) 我想从这个图像创build12个小尺寸的button,每个都有不同的颜色。 为了整洁,我想在代码中做这个,而不是在一些艺术包的外面。 任何人都可以提供一个方法(甚至是一些代码)来做到这一点? PS我知道如何在GL中使用一个荒谬的数量代码,我希望有一个更简单的方式使用核心graphics/核心animation 编辑:工作解决scheme,感谢从下面的答案精彩 CGSize targetSize = (CGSize){100,100}; UIImage* image; { CGRect rect = (CGRect){ .size = targetSize }; UIGraphicsBeginImageContext( targetSize ); { CGContextRef X = UIGraphicsGetCurrentContext(); UIImage* uiGem = [UIImage imageNamed: @"GemTop_Dull.png"]; // draw gem [uiGem drawInRect: rect]; // overlay a red rectangle CGContextSetBlendMode( X, kCGBlendModeColor ) ; CGContextSetRGBFillColor ( X, […]

按string属性的第一个字母过滤数组

我有一个具有name属性的对象的NSArray 。 我想按name筛选数组 NSString *alphabet = [agencyIndex objectAtIndex:indexPath.section]; //—get all states beginning with the letter— NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet]; NSMutableArray *listSimpl = [[NSMutableArray alloc] init]; for (int i=0; i<[[Database sharedDatabase].agents count]; i++) { Town *_town = [[Database sharedDatabase].agents objectAtIndex:i]; [listSimpl addObject:_town]; } NSArray *states = [listSimpl filteredArrayUsingPredicate:predicate]; 但是,我得到一个错误 – “不能做一个string的操作不是一个string(lhs = […]