UIScrollview使当前图像变大 [英] UIScrollview make the current Image Larger

查看:49
本文介绍了UIScrollview使当前图像变大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个包含10张图像的可滚动画廊.当我停在图像上时,我希望当前图像看起来比两侧的其他图像高一些.如何聚焦视图并调整框架?拖动结束后,将调用函数scrollViewDidEndDecelerating.如何获得对该imageview框架的引用?

I am building a scrollable gallery with 10 images. When I stop on an image, I want the current image to look little taller than the other ones on either side. How do I get the view in focus and adjust the frame ? Once the drag ends, the function scrollViewDidEndDecelerating gets called. How do I get the reference to that imageview's frame ?

推荐答案

比方说,您持有对self.imageViewsUIImageView的引用,您可以尝试类似的方法.

Let's say that you hold reference to the UIImageViews in self.imageViews, you can try something like this.

CGFloat centerX = CGRectGetMidX(self.view.bounds);
for(UIImageView imgView * in self.imageViews)
{
    if(CGRectContainsPoint(imgView, centerX)) // If imgView is close to center
    {
        imgView.transform = CGAffineTransformMakeScale(1.2f, 1.2f);
    }
    else
    {
        imgView.transform = CGAffineTransformIdentity;
    }
}

我假设您正在水平滚动,但是如果垂直滚动,则需要使用centerY.

I assumed you are scrolling horizontally, but if you are doing it vertically, you need to use centerY instead.

这篇关于UIScrollview使当前图像变大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆