i 그리드보기에서 현재 위치에서 전체 화면으로 이미지보기를 움직여야했습니다. 격자보기로 이미지를 만들었습니다.iOS의 ImageView 용 UIView 애니메이션
- (void)viewDidLoad
{
[super viewDidLoad];
imagesArray = [[NSMutableArray alloc] init];
for (int i=1; i<11; i++) {
[imagesArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"image%d.png", i]]];
NSLog(@"imagesArray:%@", imagesArray);
}
float horizontal = 20.0;
float vertical = 20.0;
for(int i=0; i<[imagesArray count]; i++)
{
if((i%3) == 0 && i!=0)
{
horizontal = 20.0;
vertical = vertical + 220.00 + 20.0;
}
imagesView = [[UIImageView alloc] initWithFrame:CGRectMake(horizontal, vertical, 310.0, 220.00)];
imagesView.userInteractionEnabled = YES;
[imagesView setImage:[imagesArray objectAtIndex:i]];
imagesView.tag = i;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
[imagesView addGestureRecognizer:tap];
[self.view addSubview:imagesView];
horizontal = horizontal + 310.0 + 20.0;
}
}
여기에 10 개의 이미지가있는 것처럼 이미지가있는 격자보기가 생성되었습니다. 3x3 격자보기를 만들었습니다. 다음
내가 그것에 탭 제스처를 추가하고 난
-(void)handleTap:(UITapGestureRecognizer *)recognizer
{
UIView *piece = recognizer.view;
[UIView animateWithDuration:1.0 animations:^{
piece.frame = CGRectMake(piece.frame.origin.x, piece.frame.origin.y, 1000, 700);
} completion:^(BOOL finished) {
}];
}
는 당신이 눌러 전체 화면으로 현재 위치에서 이미지보기 애니메이션을 만드는 방법을 나에게 말할 수 태그로 호출하여 이미지 뷰 위치를 얻고있다 그것.
패딩 당신은'CGRectInset'을 사용할 수 있습니다 –
모든면에서 이미지 주위에 100 픽셀 말을 적용하는 방법 :'piece.frame = CGRectInset (self.view.bounds, 100, 100); ' – StatusReport