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—需要获取的数];

  • 相关阅读:
    字符串转list
    vant下拉单选
    断点续传(上传)C#版
    7z压缩测试
    SQL SERVER查看表字段信息
    FTP安全组设置
    Unable to find @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest
    Charles 抓包使用教程
    董明珠语录
    京东 Vue3 组件库 nutui 3.0 发布,支持小程序开发
  • 原文地址:https://www.cnblogs.com/ysh-LOVE-hmx-5201314/p/4276036.html
Copyright © 2011-2022 走看看