1.cell改變選中顏色背景圖片分割線的顏色
1.系統(tǒng)默認(rèn)的顏色設(shè)置
//無色
cell.selectionStyle = UITableViewCellSelectionStyleNone;//藍(lán)色
cell.selectionStyle = UITableViewCellSelectionStyleBlue; //灰色
cell.selectionStyle = UITableViewCellSelectionStyleGray;
2.自定義顏色和背景設(shè)置
3.改變UITableViewCell選中時(shí)背景色:
UIColor *color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通過RGB來定義自己的顏色
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];
3.自定義UITableViewCell選中時(shí)背景
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease];
還有字體顏色
cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color]
4.設(shè)置tableViewCell間的分割線的顏色
[theTableView setSeparatorColor:[UIColor xxxx ]];
2.collection的cell重排編組
//長按手勢
_longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(lonePressMoving:)];
[self.xtCollectionView addGestureRecognizer:_longPress];
- (void)lonePressMoving:(UILongPressGestureRecognizer *)longPress
{
switch (_longPress.state) {
case UIGestureRecognizerStateBegan: {
{
NSIndexPath *selectIndexPath = [self.xtCollectionView indexPathForItemAtPoint:[_longPress locationInView:self.xtCollectionView]];
// 找到當(dāng)前的cell
XTCollectCell *cell = (XTCollectCell *)[self.xtCollectionView cellForItemAtIndexPath:selectIndexPath];
// 定義cell的時(shí)候btn是隱藏的, 在這里設(shè)置為NO
[cell.btnDelete setHidden:NO];
[_xtCollectionView beginInteractiveMovementForItemAtIndexPath:selectIndexPath];
}
break;
}
case UIGestureRecognizerStateChanged: {
[self.xtCollectionView updateInteractiveMovementTargetPosition:[longPress locationInView:_longPress.view]];
break;
}
case UIGestureRecognizerStateEnded: {
[self.xtCollectionView endInteractiveMovement];
break;
}
default: [self.xtCollectionView cancelInteractiveMovement];
break;
}
}
- (void)collectionView:(UICollectionView *)collectionView moveItemAtIndexPath:(nonnull NSIndexPath *)sourceIndexPath toIndexPath:(nonnull NSIndexPath *)destinationIndexPath
{
NSIndexPath *selectIndexPath = [self.xtCollectionView indexPathForItemAtPoint:[_longPress locationInView:self.xtCollectionView]];
// 找到當(dāng)前的cell
XTCollectCell *cell = (XTCollectCell *)[self.xtCollectionView cellForItemAtIndexPath:selectIndexPath];
[cell.btnDelete setHidden:YES];
[self.array exchangeObjectAtIndex:sourceIndexPath.item withObjectAtIndex:destinationIndexPath.item];
[self.xtCollectionView reloadData];
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者