lol盒子重点内容

//AFN函数 — imageview加载网络图片并且获取图片,获取之后存储到手机
  [image setImageWithURLRequest :[ NSURLRequest requestWithURL :[ NSURL URLWithString :[ NSString stringWithFormat : @"%@" ,skin. bigImg ]] ] placeholderImage : nil success :^( 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) {
        [
self showToastWithText : @" 不允许保存 " ];
    }
else {
        [
self showToastWithText : @" 保存成功 " ];
    }
}

_player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:file] error:nil];
//            NSLog(@"%@",[NSURL fileURLWithPath:file]);
//            [_player play];
//audioplayer第三方类库播放文件
           
AudioPlayer *player = [ AudioPlayer sharePlayer ];
            [player playWithDataSourceType:DataSourceTypeLocal withURLString:file];

    //下载文件
           
NSString *string = [ NSString stringWithFormat : HERO_SOUND_DESC_URL ,pathName,fileName];
           
NSURL *url = [ NSURL URLWithString :[string stringByAddingPercentEscapesUsingEncoding : NSUTF8StringEncoding ]];
           
NSURLRequest *request = [ NSURLRequest requestWithURL :url];
           
           
AFHTTPRequestOperation *operation = [[ AFHTTPRequestOperation alloc ] initWithRequest :request];
            operation.
inputStream = [ NSInputStream inputStreamWithURL :url];
            operation.
outputStream = [ NSOutputStream outputStreamToFileAtPath :file append : NO ];
            [operation
setCompletionBlockWithSuccess :^( AFHTTPRequestOperation *operation, id responseObject) {
               
NSLog ( @" 下载成功 " );
                [
_tableview reloadData ];
            }
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 :[ UIScrollView class ]]) {
            [scrollview setZoomScale:1.0];
        }
    }
   
HeroSkin *skin = [ _heroskin objectAtIndex : _pageIndex ];
   
_namelabel . text = skin. name ;
   
_pricelabel . text = skin. price ;
   
_pagelabel . text = [ NSString stringWithFormat : @"%ld of %lu" , _pageIndex + 1 ,( unsigned long ) _heroskin . count ];
   
NSLog ( @"%ld" ,( long ) _pageIndex );
}

//图片摇动
-(
void )ImageShake
{
   
CABasicAnimation *basic = [ CABasicAnimation animationWithKeyPath : @"transform.rotation.z" ];
    basic.
fromValue = [ NSNumber numberWithFloat :- M_PI / 16 ];
    basic.
toValue = [ NSNumber numberWithFloat : M_PI / 16 ];
    basic.
duration = 0.1 ;
    basic.
repeatCount = 3 ;
    [imageview.layer addAnimation:basic forKey:@"animateLayer"];
//震动一次
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}

//检测motion
-(
void )motionEnded:( UIEventSubtype )motion withEvent:( UIEvent *)event
{
   
if (motion == UIEventSubtypeMotionShake ) {
        [
self ImageShake ];
        [
player play ];
    }
}

//计算string字符串的frame大小
-(
CGSize )getStringRect:( NSString *)str
{
   
if (str. length < 1 ) {
       
return CGSizeMake ( 0 , 0 );
    }
   
CGSize size;
   
NSAttributedString *string = [[ NSAttributedString alloc ] initWithString :str];
   
//    NSDictionary *attribute= @{NSFontAttributeName:@12};
    size = [string
boundingRectWithSize : CGSizeMake ( 280 , 500 ) options : NSStringDrawingTruncatesLastVisibleLine |
           
NSStringDrawingUsesLineFragmentOrigin |
           
NSStringDrawingUsesFontLeading context : nil ]. size ;
   
return size;
}

-( CGFloat )caculateLabelHeightWith:( float )fontsize String:( NSString *)str
{
   
UIFont *font = [ UIFont systemFontOfSize :fontsize];
   
CGSize size = CGSizeMake ( 300 , 700 );
   
CGSize descriptionSize = [str sizeWithFont :font constrainedToSize :size lineBreakMode : NSLineBreakByWordWrapping ];
   
return descriptionSize. height ;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值