ios - 滚动 UIImageView 图像

标签 ios objective-c uiimageview

我想滚动我的 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/

相关文章:

ios - 重大位置变更如何运作?

objective-c - 澄清 Cocoa 语法中的星号和下划线

ios - Storyboard设计 iOS 所需的分辨率图形

iphone - UIView animateWithDuration 仅动画一次

ios - 从 URL 字符串中提取的 UITableViewController 中的图像加载缓慢

ios - ld :Framework not found for architecture i386

ios - 我是 Storyboard中的 5 个 Controller ,如何以编程方式返回官方初始 Controller ?

android - 带有API的移动信用卡刷卡系统

objective-c - 在 Cocoa 应用程序中存储数据的位置?

ios - 多线程 iOS 中的通知