IOS開發UIImage中stretchableImageWithLeftCapWidth方法的解釋


- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapWidth;

 

Creates and returns a new image object with the specified cap values.

 

During scaling or resizing of the image, areas covered by a cap are not scaled or resized. Instead, the 1-pixel wide area not covered by the cap in each direction is what is scaled or resized. This technique is often used to create variable-width buttons, which retain the same rounded corners but whose center region grows or shrinks as needed.

上面是官方文檔上得解釋。意思就是用來創建一個內容可拉伸,而邊角不拉伸的圖片,需要兩個參數,第一個是左邊不拉伸區域的寬度,第二個參數是上面不拉伸的高度。那么接下來的一個像素會被拉伸。例如,leftCapHeight為6,topCapHeight為8。那么,圖片左邊的6個像素,上邊的8個像素。不會被拉伸,而左邊的第7個像素,上邊的第9個像素這一塊區域將會被拉伸。剩余的部分也不會被拉伸。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM