久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

獲取 UIScrollView 內(nèi)容的可見矩形

Getting the visible rect of an UIScrollView#39;s content(獲取 UIScrollView 內(nèi)容的可見矩形)
本文介紹了獲取 UIScrollView 內(nèi)容的可見矩形的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

如何找出屏幕上實(shí)際可見的顯示視圖內(nèi)容的矩形 (CGRect).

How can I go about finding out the rect (CGRect) of the content of a displayed view that is actually visible on screen.

myScrollView.bounds

上面的代碼在沒有縮放時(shí)有效,但是一旦你允許縮放,它會在縮放比例不是 1 時(shí)中斷.

The code above works when there's no zooming, but as soon as you allow zooming, it breaks at zoom scales other than 1.

為了澄清,我想要一個(gè)包含滾動視圖內(nèi)容的可見區(qū)域的 CGRect,相對于內(nèi)容.(即,如果它是縮放比例 2,矩形的大小將是滾動視圖大小的一半,如果它是縮放比例 0.5,它將是兩倍.)

To clarify, I want a CGRect that contains the visible area of the scroll view's content, relative to the content. (ie. if it's a zoom scale 2, the rect's size will be half of the scroll view's size, if it's at zoom scale 0.5, it'll be double.)

推薦答案

回答我自己的問題,主要感謝 Jim Dovey 的回答,這并沒有完全解決問題,但給了我回答的基礎(chǔ):

Answering my own question, mostly thanks to Jim Dovey's answer, which didn't quite do the trick, but gave me the base for my answer:

CGRect visibleRect;
visibleRect.origin = scrollView.contentOffset;
visibleRect.size = scrollView.bounds.size;

float theScale = 1.0 / scale;
visibleRect.origin.x *= theScale;
visibleRect.origin.y *= theScale;
visibleRect.size.width *= theScale;
visibleRect.size.height *= theScale;

主要區(qū)別在于 visibleRect 的大小應(yīng)該是 scrollView.bounds.size,而不是 scrollView.contentSize 是內(nèi)容視圖的大小.還稍微簡化了數(shù)學(xué),并沒有完全看到 isless() 的用途,它會在代碼更大時(shí)破壞代碼.

The main difference is that the size of the visibleRect ought to be scrollView.bounds.size, rather than scrollView.contentSize which is the size of the content view. Also simplified the math a bit, and didn't quite see the use for the isless() which would break the code whenever it's greater.

這篇關(guān)于獲取 UIScrollView 內(nèi)容的可見矩形的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時(shí)暫停 NSTimer)
主站蜘蛛池模板: 国产美女在线播放 | 亚洲视频免费在线观看 | 亚洲国产成人av好男人在线观看 | 91一区 | 亚洲一区二区免费 | 成人国产精品久久 | 欧美在线一区二区三区 | 久久91| 91色视频在线观看 | yeyeav| 国产精品一区二区三区四区 | 中文字幕不卡视频在线观看 | 午夜视频在线播放 | 亚洲国产一区二区视频 | 精品视频在线观看 | 91精品国产91久久久久游泳池 | 久久国产精品一区二区三区 | 午夜电影网站 | 国产亚洲一区二区在线观看 | 亚洲第一在线 | 日韩精品欧美精品 | 久久亚洲一区二区 | 性一交一乱一透一a级 | 精品一级电影 | 亚洲日日操 | 欧美国产精品一区二区三区 | 九九九久久国产免费 | 精品伊人久久 | 福利片一区二区 | 久久精品欧美视频 | 国产精品日韩在线 | 金莲网| 亚洲精品一二三区 | 欧美日韩福利视频 | 免费黄色片在线观看 | 日韩在线一区二区 | 国产亚洲精品精品国产亚洲综合 | 黄色av一区| 青青草在线播放 | 岛国av免费观看 | 久久免费精品 |