本文介紹了UIImage 在開始時不適合 UIScrollView的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一張像這樣的圖片:
I have an image like:
當我將圖像加載到 uiimageview,然后作為子視圖添加到 uiscrollview 時,開始時圖像顯示如下:
When I load the image to uiimageview and then adding as a subview to uiscrollview, at start the image is showing like:
問題是我想在開始時看到所有適合屏幕的圖像,但它顯示已經縮放.有沒有辦法處理這個請幫忙...
The problem is I want to see all the image fit to screen at start but it is showing already zoomed. Is there a way to handle this please help ...
我有這樣的代碼:
[self.view addSubview:scrollView];
UIImageView *tempImageView =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tree.jpg"]];
self.imageView = tempImageView;
[tempImageView release];
[scrollView setContentMode:UIViewContentModeScaleAspectFit];
[imageView sizeToFit];
scrollView.backgroundColor=[UIColor blackColor];
scrollView.contentSize = imageView.frame.size;
scrollView.minimumZoomScale = scrollView.frame.size.width / imageView.frame.size.width;
scrollView.maximumZoomScale = 4.0;
[scrollView setZoomScale:1.0];
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
[scrollView addSubview:imageView];
推薦答案
可能你正在尋找這個,
UIImageView *tempImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Watson.jpg"]] autorelease];
tempImageView.frame = scrollView.bounds;
self.imageView = tempImageView;
scrollView.backgroundColor = [UIColor blackColor];
scrollView.minimumZoomScale = 1.0 ;
scrollView.maximumZoomScale = imageView.image.size.width / scrollView.frame.size.width;
scrollView.zoomScale = 1.0;
scrollView.delegate = self;
[scrollView addSubview:imageView];
這篇關于UIImage 在開始時不適合 UIScrollView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!