다른 UIView 또는 다른 요소에서 UICollectionViewCell을 드래그하려고합니다. UICollectionViewCell의 하위 클래스를 만들었습니다.다른 요소에서 UICollectionViewCell 드래그
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
self.dragObject=self;
self.homePosition = CGPointMake(self.frame.origin.x,
self.frame.origin.y);
[self.superview.superview bringSubviewToFront:self];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint touchPoint = [[touches anyObject] locationInView:self.superview];
CGRect newDragObjectFrame = CGRectMake(touchPoint.x - touchOffset.x,
touchPoint.y - touchOffset.y,
self.frame.size.width,
self.frame.size.height);
self.frame = newDragObjectFrame;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGRect newFrame = CGRectMake(self.homePosition.x, self.homePosition.y,
self.frame.size.width,
self.frame.size.height);
[UIView animateWithDuration:0.2
animations:^{
self.frame = newFrame;
}];
}
내가 끌어 UICollectionView의 모든 UICollectionViewCell을 삭제할 수 있습니다 :
이 내 세포 클래스 UICollectionViewCell의 서브 클래스입니다. 그러나 화면의 다른 요소에 셀을 끌 수는 없습니다. 예를 들어 또 다른 UICollectionView 또는 UIView.
clipToBounds 속성을 "false"로 설정하면 셀을 아무 곳이나 드래그 할 수 있지만 스크롤 된 셀처럼 오버플로 콘텐츠는 숨기지 않습니다. 이 그림에서
, clipToBounds = 거짓 :
빛나는 감사합니다 ... – onivi