lol盒子重點內容,lol盒子內容
//AFN函數 — imageview載入網狀圖片並且擷取圖片,擷取之後儲存到手機 [image setImageWithURLRequest:[NSURLRequestrequestWithURL:[NSURLURLWithString:[NSStringstringWithFormat:@"%@",skin.bigImg]] ] placeholderImage:nilsuccess:^(NSURLRequest*request, NSHTTPURLResponse *response, UIImage *image) { UIImageWriteToSavedPhotosAlbum(image,self, @selector(image:didFinishSavingWithError:contextInfo:), nil);- (void)image:(UIImage*)image didFinishSavingWithError:(NSError*)error contextInfo:(void*)contextInfo
{
if (error) {
[selfshowToastWithText:@"不允許儲存"];
}else{
[selfshowToastWithText:@"儲存成功"];
}}
_player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:file] error:nil];
// NSLog(@"%@",[NSURL fileURLWithPath:file]);
// [_player play];
//audioplayer第三方類庫播放檔案
AudioPlayer*player = [AudioPlayersharePlayer]; [player playWithDataSourceType:DataSourceTypeLocalwithURLString:file];
//下載檔案
NSString*string = [NSStringstringWithFormat:HERO_SOUND_DESC_URL,pathName,fileName];
NSURL*url = [NSURLURLWithString:[stringstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSURLRequest*request = [NSURLRequestrequestWithURL:url];
AFHTTPRequestOperation*operation = [[AFHTTPRequestOperationalloc]initWithRequest:request];
operation.inputStream= [NSInputStreaminputStreamWithURL:url];
operation.outputStream= [NSOutputStreamoutputStreamToFileAtPath:fileappend:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation*operation, id responseObject) {
NSLog(@"下載成功");
[_tableviewreloadData];
} failure:^(AFHTTPRequestOperation*operation, NSError *error) {
NSLog(@"下載失敗");
}]; [operation start];//在停止滑動的時候將scrollview的縮放變為1倍-(void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView
{ _pageIndex = scrollView.contentOffset.x/SCREEN_WIDTH;
for (UIScrollView*scrollview in scrollView.subviews)
{
if ([scrollview isKindOfClass:[UIScrollViewclass]]) { [scrollview setZoomScale:1.0]; }
}
HeroSkin*skin = [_heroskinobjectAtIndex:_pageIndex];
_namelabel.text= skin.name;
_pricelabel.text= skin.price;
_pagelabel.text= [NSStringstringWithFormat:@"%ld of %lu",_pageIndex+1,(unsignedlong)_heroskin.count];
NSLog(@"%ld",(long)_pageIndex);}
//圖片搖動
-(void)ImageShake
{
CABasicAnimation*basic = [CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"];
basic.fromValue= [NSNumbernumberWithFloat:-M_PI/16];
basic.toValue= [NSNumbernumberWithFloat:M_PI/16];
basic.duration= 0.1;
basic.repeatCount= 3; [imageview.layeraddAnimation:basic forKey:@"animateLayer"];//震動一次 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);}
//檢測motion
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent*)event
{
if (motion == UIEventSubtypeMotionShake) {
[selfImageShake];
[playerplay];
}}
//計算string字串的frame大小
-(CGSize)getStringRect:(NSString*)str
{
if (str.length<1) {
returnCGSizeMake(0,0);
}
CGSize size;
NSAttributedString*string = [[NSAttributedStringalloc]initWithString:str];
// NSDictionary *attribute= @{NSFontAttributeName:@12};
size = [string boundingRectWithSize:CGSizeMake(280,500)options:NSStringDrawingTruncatesLastVisibleLine|
NSStringDrawingUsesLineFragmentOrigin|
NSStringDrawingUsesFontLeadingcontext:nil].size;
return size;}
-(CGFloat)caculateLabelHeightWith:(float)fontsize String:(NSString*)str
{
UIFont *font = [UIFontsystemFontOfSize:fontsize];
CGSize size = CGSizeMake(300,700);
CGSize descriptionSize = [str sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
return descriptionSize.height;}