iOS開發項目—07圖片展開

來源:互聯網
上載者:User

標籤:style   blog   http   color   strong   width   

iOS開發項目—07圖片展開

一、簡單說明

1.代碼說明:

圖片處理代碼:

1 + (UIImage *)resizedImage:(NSString *)name2 {3     UIImage *image = [UIImage imageWithName:name];4     return [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];5 }6 //以長度的一半,高度的一半為中心進行展開。

調用展開(1)

 1 /** 2  *  點擊標題點擊 3  */ 4 - (void)titleClick:(UIButton *)titleButton 5 { 6     // 換成箭頭向上 7     [titleButton setImage:[UIImage imageWithName:@"navigationbar_arrow_up"] forState:UIControlStateNormal]; 8      9     10     // 快顯功能表11     UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];12     button.backgroundColor = [UIColor blueColor];13     14     15     HMPopMenu *menu = [[HMPopMenu alloc ] initWithContentView:nil];16     menu.delegate = self;17     menu.arrowPosition = HMPopMenuArrowPositionCenter;18     //    menu.dimBackground = YES;19     [menu showInRect:CGRectMake(0, 0, 100, 200)];20 }

效果:

 

2.快顯功能表存在的問題:當寬度大於217的時候,就會有問題。

代碼:

 1 /** 2  *  點擊標題點擊 3  */ 4 - (void)titleClick:(UIButton *)titleButton 5 { 6     // 換成箭頭向上 7     [titleButton setImage:[UIImage imageWithName:@"navigationbar_arrow_up"] forState:UIControlStateNormal]; 8      9     // 快顯功能表10     UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];11     button.backgroundColor = [UIColor blueColor];12     13     HMPopMenu *menu = [[HMPopMenu alloc ] initWithContentView:nil];14     menu.delegate = self;15     menu.arrowPosition = HMPopMenuArrowPositionCenter;16     //    menu.dimBackground = YES;17     [menu showInRect:CGRectMake(0, 0, 300, 200)];18 }

實現效果:

產生問題的原因:展開圖片的方式不對。展開讓箭頭的實現出現了問題,可以嘗試換一種展開的方式。

之前的展開是對中間的百分之五十進行展開,變換為展開最右邊的部分也不能徹底的解決問題。

說明:新浪官方在面對這個問題的時候,美工把菜單的圖片設定的很大,為434,所以如果展開的範圍在217內,那就不會有影響。(調整CGRectMake的寬度),在做上邊有小箭頭的圖片時,把圖片的寬度做足一點。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.