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

滾動(dòng)視圖 iphone 周圍的陰影或邊框

Shadow or Border around a scrollview iphone(滾動(dòng)視圖 iphone 周圍的陰影或邊框)
本文介紹了滾動(dòng)視圖 iphone 周圍的陰影或邊框的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我想在 uiscrollview 周圍繪制邊框/陰影,我知道我可以通過(guò)額外的視圖或滾動(dòng)視圖到達(dá)那里,但不喜歡處理缺點(diǎn),但我聽(tīng)說(shuō)應(yīng)該有可能直接繪制邊框到滾動(dòng)視圖,這就是我想要的.

i would like to draw a border / shadow around a uiscrollview, i know that i could get there with an additional view or scrollview but dont like the handling an drawbacks but i heard that there should be a possibility to dirctly draw a border to a scrollview and that is what i would prefer.

我是 iphone 開(kāi)發(fā)的新手,任何答案都會(huì)有所幫助.

I am quiet new to iphone developement,any answer would helpful.

推薦答案

如果您使用滾動(dòng)視圖(或任何 UIView)的 layer 屬性,您可以輕松獲得實(shí)心邊框...

If you use the layer property of your scroll view (or any UIView) you can easily get a solid border...

#import <QuartzCore/QuartzCore.h>
...
myView.layer.borderWidth = 2;
myView.layer.borderColor = [UIColor blackColor].CGColor;

您也可以通過(guò)設(shè)置 layer.shadow* 屬性來(lái)使用圖層來(lái)應(yīng)用實(shí)時(shí)陰影,但是使用此技術(shù)可能會(huì)降低性能,因此我通常更喜歡使用以下更復(fù)雜的方法,但更高效的技術(shù).您可以創(chuàng)建一個(gè)中間透明、邊緣有陰影的 PNG 圖像 - 它需要有 9 個(gè)不同的區(qū)域:每個(gè)角 4 個(gè),每個(gè)邊緣 4 個(gè),中間有一個(gè)完全透明的 1x1 像素區(qū)域.例如,如果您的陰影在圖像中延伸 6 個(gè)像素,則您的圖像將是 13x13,具有 6 像素寬/高邊框和 1x1 區(qū)域在中間.然后使用以下方法將其設(shè)置為可縮放圖像:

You can also use the layer to apply real-time shadows by setting the layer.shadow* properties, but performance can be slow with this technique, so I generally prefer to use the following more complex, but more performant technique. You can create a PNG image with transparency in the middle and shadows around the edge - it needs to have 9 distinct areas: 4 for each corner, 4 for each edge, and a completely transparent 1x1 pixel area in the middle. For example if your shadow extends 6 pixels into your image, your image would be 13x13 with the 6 pixel wide/high borders and the 1x1 area in the middle. Then you set it as a scalable image using:

newImage = [image stretchableImageWithLeftCapWidth:6 topCapHeight:6];

更新: 由于 iOS 5.0 stretchableImageWithLeftCapWidth:topCapHeight: 已棄用,因此僅當(dāng)您仍想支持 iOS 4.x 設(shè)備時(shí)才使用此功能.如果您只想支持 iOS 5.0+ 設(shè)備,請(qǐng)改用:

UPDATE: Since iOS 5.0 stretchableImageWithLeftCapWidth:topCapHeight: is deprecated so only use this if you still want to support iOS 4.x devices. If you want to support only iOS 5.0+ devices use this instead:

newImage = [image resizableImageWithCapInsets:UIEdgeInsetsMake(6, 6, 6, 6)];

然后將圖像放在父視圖上,這樣它就占據(jù)了滾動(dòng)視圖的整個(gè)區(qū)域.如果您希望陰影覆蓋您的可滾動(dòng)元素,(因此您的滾動(dòng)視圖看起來(lái)嵌入/位于頁(yè)面的其余部分之后)然后在頂部放置一個(gè)透明的 UIView 并在其上放置陰影圖像,以便它顯示到您的滾動(dòng)視圖在它后面.

Then you put the image on the parent view so it takes up the entire area of the scroll view. If you want the shadows to go OVER your scrollable elements, (so your scroll view looks inset/behind the rest of the page) then place a transparent UIView over the top with the shadow image on it so that it shows through to your scroll view behind it.

這篇關(guān)于滾動(dòng)視圖 iphone 周圍的陰影或邊框的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設(shè)置滾動(dòng)視圖內(nèi)容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動(dòng)滾動(dòng))
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運(yùn)行時(shí),使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會(huì)導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 国产精品免费福利 | 国产精品久久国产愉拍 | 国产精彩视频在线观看 | 黄色在线免费观看视频网站 | 九九亚洲精品 | 国产成人久久精品一区二区三区 | 美女啪啪国产 | 欧美午夜精品理论片a级按摩 | 亚洲综合久久精品 | 手机在线一区二区三区 | 久久99精品国产99久久6男男 | 美女一级毛片 | 99精品国产一区二区三区 | 国产日韩欧美电影 | av在线播放网址 | 久久久久久久久久久久久久av | 国产精品美女www | 99精品99| 欧美精品在线一区 | 久久精品一区二区 | 日韩欧美国产一区二区 | 欧美一区二区 | 毛片免费看| 日韩视频在线一区二区 | 视频1区2区 | 北条麻妃av一区二区三区 | 99视频在线 | 麻豆av一区二区三区久久 | 日韩av一区二区在线 | 国产小视频精品 | 9999精品视频 | 日本久久精品视频 | 亚洲成人在线免费 | 亚洲成人蜜桃 | 91精品国产91久久久久久吃药 | 亚洲国产一区二区三区 | 国产精品一区二区三区久久久 | 国产 欧美 日韩 一区 | 精品一区在线 | 中文字幕日韩一区二区 | 日韩在线精品视频 |