zoukankan      html  css  js  c++  java
  • iOS小知识点

    获取图片缓存

    1.导入  

    #import "SDImageCache.h"

    //把B单位转换为M

    [NSString stringWithFormat:@"%.2fM",(double)[[SDImageCache sharedImageCache] getSize]/1000/1000];

    清除图片缓存

    [[SDImageCache sharedImageCache] clearDisk];

    获取某文件夹中所有文件缓存

    //文件夹枚举器,可以枚举这个文件夹内以及这个文件夹的子文件夹中的所有文件

                NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:<[CommonTool fileDownloadPath]>>>需要遍历的文件夹路经];

    unsigned long long totalSize = 0;

      while ([enumerator nextObject]) 

    {

      totalSize+=[[enumerator fileAttributes] fileSize];

       

    }

     [NSString stringWithFormat:@"%.2fM",(double)totalSize/1000/1000];

    清理文件缓存

    [[NSFileManager defaultManager] removeItemAtPath:<[CommonTool fileDownloadPath]>>>需要删除的文件夹路经 error:nil];

    //push时自动隐藏tabBar

    vc.hidesBottomBarWhenPushed = YES;

    自适应高度

    CGRect rect = [_news.intr-需要获取的字符串- boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-30>-需要多宽折行, 0) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:14]} context:nil];

    return rect.size.height+30;

    获取键盘的高度输入框自适应

     _inputView 是自定义的一个 View 加上 textField 的输入框 

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];

    - (void)keyboardWillChangeFrame:(NSNotification *)noti{

       // NSLog(@"%@",noti.userInfo);

        CGRect rect = [[noti.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];

        [UIView animateWithDuration:[[noti.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue] animations:^{

            _inputView.frame = CGRectMake(0, rect.origin.y-40, SCREEN_WIDTH, 40);

            _tableView.frame = CGRectMake(0, 0, SCREEN_WIDTH, _inputView.frame.origin.y);

        }];

    }

     ---用滑动方式让键盘下去

    -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{

         [self.view endEditing:YES];

    }

    气泡聊天 专用 从某个像素点拉申

    self.bubbleImageView.image = [[UIImage imageNamed:@"bubbleSelf.png"] stretchableImageWithLeftCapWidth:25 topCapHeight:20];

    //设置照片为圆形 常用语头像

    self.headerImageView.layer.cornerRadius = 30—照片大小的半径;

        self.headerImageView.layer.masksToBounds = YES;

    设置应用图标的角标

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:number—需要获取的数];

  • 相关阅读:
    React网络请求fetch之post请求
    从ajax到fetch到axios
    了解 Fetch API与Fetch+Async/await
    new FormData() 前端上传文件图片到服务器
    ES7之async/await同步编程异步函数
    React网络请求fetch之get请求
    React非受控组件
    React 组件优化之函数防抖节流---使用 debounce +throttle 函数
    【LeetCode】86. Partition List
    【LeetCode】122. Best Time to Buy and Sell Stock II
  • 原文地址:https://www.cnblogs.com/ysh-LOVE-hmx-5201314/p/4276036.html
Copyright © 2011-2022 走看看