我想滚动我的 UIImageView 中的图像,以防我的手指在 UIImageView 区域内并且我正在移动我的手指。我正在尝试使用 objective-c 来做到这一点。我让它动起来了,但它表现得很奇怪而且不能正常工作。你能告诉我怎么做吗???
这就是我正在做的:
- (void)touchesMoved :(NSSet *)touches withEvent:(UIEvent *)event{
for (UITouch *touch in touches) {
CGPoint touchLocation = [touch locationInView:self];
for (id sublayer in view_shape.sublayers) {
if (sublayer ==imageView.layer) {
if (CGRectContainsPoint(imageView.frame, touchLocation)) {
imageView.layer.contentsRect = CGRectMake( touchLocation.x/1000,
touchLocation.y/1000,
imageView.layer.contentsRect.size.width,
imageView.layer.contentsRect.size.height);
}
}
}
}
}
最佳答案
为什么不使用 scrollView 而只是将 imageView 添加到它
关于ios - 滚动 UIImageView 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34056315/