zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    Django【十五】pillow模块使用
    Django【十四】内置的anth认证
    Django【十三】form组件。
    Django【十二】中间价
    Django【十一】cookie-sesson
    Django【十】Ajax
    Django【八】多表操作
    Django【九】事务和锁
    python协程
    python多线程
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4511938.html
Copyright © 2011-2022 走看看