0
進出口使用以下代碼來的UIImageView動畫顯示不
UIImage* img1 = [UIImage imageNamed:@"1.gif"];
UIImage* img2 = [UIImage imageNamed:@"2.gif"];
UIImage* img3 = [UIImage imageNamed:@"3.gif"];
UIImage* img4 = [UIImage imageNamed:@"4.gif"];
UIView *loadingView = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4, self.view.frame.size.height/4, 170, 170)];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(65, 40, loadingView.bounds.size.width, loadingView.bounds.size.height)];
loadingView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
loadingView.clipsToBounds = YES;
loadingView.layer.cornerRadius = 10.0;
loadingView.center = self.view.center;
imgView.backgroundColor = [UIColor clearColor];
imgView.center = loadingView.center;
imgView.animationImages = @[img1, img2, img3, img4];
imgView.animationDuration = 1.0*1.0;
[loadingView addSubview: imgView];
[self.view addSubview:loadingView];
[imgView startAnimating];
- 我已經定義了四個uiimages最初
- 的視圖中居中的圖像I所定義的loadingview,我已經它爲中心,以屏幕
- 我已經定義了一個imageview,我已經將它集中到加載視圖。
- 我已添加的ImageView是loadingView的子視圖和我已經加入裝載視圖到view.Then IM動畫化的ImageView
的問題是沒有被示出的imaeview當我運行這碼。我怎樣才能解決這個問題?
我想你'frame'是不正確的,因爲其他的代碼是正確的,由於錯誤的框架是不可見的,嘗試調試。 – iphonic
imgView.center = loadingView.center;是不正確的,並用這段代碼正確的動畫,你需要打破圖像分開PNG/JPEG文件。 –
使用SDWebImage設置GIF圖像 – Birendra