關(guān)于性能優(yōu)化

  1. 設(shè)置圓角
-(UIImage *)avaterImageWithImage:(UIImage *)image size:(CGSize)size backColor:(UIColor *)backColor{
    CGRect rect = CGRectMake(0, 0, size.width, size.height);
    UIGraphicsBeginImageContextWithOptions(size, true, 0);
    //0.背景填充
    [backColor setFill];
    UIRectFill(rect);
    //1.實例化圓形路徑
    UIBezierPath *path =  [UIBezierPath bezierPathWithOvalInRect:rect];
    [path addClip];
    //2.在指定區(qū)域拉伸屏幕
    [image drawInRect:rect];
    //3.繪制內(nèi)切的圓形
    [[UIColor darkGrayColor] setStroke];
    path.lineWidth = 2;
    [path stroke];
    //4.獲取image
    UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
    //5.關(guān)閉上下文
    UIGraphicsEndImageContext();
    return result;
}

  1. 柵格化
  缺點耗電會增加
//異步繪制
    self.layer.drawsAsynchronously = YES;
    //柵格化
    self.layer.shouldRasterize = YES;
    //指定分辨率
    self.layer.rasterizationScale = [UIScreen mainScreen].scale;

3.cell里不使用block
delegate運行成本低,block成本很高。
cell里的回調(diào)事件通過delegate處理,cell由于復(fù)用會反復(fù)執(zhí)行賦值操作。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容