你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS開發(17)之UIImageView控件

IOS開發(17)之UIImageView控件

編輯:IOS開發綜合

1 前言
顯示給用戶圖片視圖,其視圖大小控制比較麻煩

2 代碼實例
ZYViewController.m:


[plain]
@synthesize myImageView; 
 
- (void)viewDidLoad 

    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    UIImage *macBook = [UIImage imageNamed:@"Apple.png"]; 
//    myImageView = [[UIImageView alloc] initWithImage:macBook];//不改變圖片的長寬比例 
    myImageView = [[UIImageView alloc] initWithFrame:self.view.frame];//使圖片適應整個視圖窗 
    myImageView.image = macBook; 
    myImageView.center = self.view.center; 
    [self.view addSubview:myImageView]; 
     

@synthesize myImageView;

- (void)viewDidLoad
{
    [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.
    UIImage *macBook = [UIImage imageNamed:@"Apple.png"];
//    myImageView = [[UIImageView alloc] initWithImage:macBook];//不改變圖片的長寬比例
    myImageView = [[UIImageView alloc] initWithFrame:self.view.frame];//使圖片適應整個視圖窗
    myImageView.image = macBook;
    myImageView.center = self.view.center;
    [self.view addSubview:myImageView];
   
}
保持原有的比例結果:

 

 \
 

充滿屏幕運行結果:

 


 

\
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved