iOS學習之 播放gif動畫

使用UIWebView播放web

// 設定位置和大小
CGRect frame = CGRectMake(50,50,0,0);
frame.size = [UIImage p_w_picpathNamed:@"xhr.gif"].size;
// 讀取gif圖片數據
NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"xhr" ofType:@"gif"]];
// view生成
UIWebView *webView = [[UIWebView alloc] initWithFrame:frame];
webView.userInteractionEnabled = NO;//用戶不可交互
[webView loadData:gif MIMEType:@"p_w_picpath/gif" textEncodingName:nil baseURL:nil];
[self.view addSubview:webView];
相關文章
相關標籤/搜索