Giter Site home page Giter Site logo

ppasyncdrawingkit's Introduction

PPAsyncDrawingKit

Build Status

Languages Platform Xcode

这是一个轻量的异步绘制框架,实现一系列 UIKit 基础控件。

关于 Core Text 结构问题:Apple Dev (About Core Text)

#Features

  • 使用多线程技术进行绘制,不阻塞线程,保证复杂界面的流畅
  • 高速滑动时,自动停止绘制
  • 保持 FPS 在低端设备上稳定在 60,减小抖动
  • 使用简单
  • 高性能圆角图片
  • 排版,绘制富文本
  • 一次性绘制多个富文本到同一个 view 上,减少创建多个 view
UIKit PPAsyncDrawingKit Feature
UIControl PPControl
UILabel PPTextView PPMultiplexTextView
UITextView PPEditableTextView
UIImageView PPImageView
UIButton PPButton

#TODO

  • Editable text view
  • Animation Image
  • 完善注释
  • 更多的 CoreText 样式

#Demo 为了达到效果,请在真机运行 Demo。

在复杂的场景下高速滑动 FPS 对比:

  • 测试环境 iPhone 5 (iOS 10.2)
  • 使用多线程进行绘制,基本能稳定在60 左右
  • 在主线程进行绘制,抖动较大,有非常明显的卡顿

###PPMultiplexTextView 将多个AttributedString根据各自的frame合并到同一个view上,并且支持交互。

####新浪微博Example:Project/Feeds Demo/View

####微信朋友圈Example:project/Text Example/PPMultiplexTextExample.m

层次结构:

###PPTextView

CGSize maxSize = CGSizeMake(CGRectGetWidth(self.view.bounds) - 24.0f, CGFLOAT_MAX);

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"@谷大白话:Super Moon"];
[attributedString pp_setFont:[UIFont systemFontOfSize:15.0f]];

PPTextView *textView = [[PPTextView alloc] init];

// 下面 2 个方法可以获取文字的大小
// PPTextLayout *textLayout = [PPTextLayout new];
// textLayout.attributedString = attributedString;
// textLayout.maxSize = maxSize;
// CGSize textSize = textLayout.layoutSize;
OR
// CGSize textSize = [attributedString pp_sizeConstrainedToSize:maxSize];

// 下面 2 个方法可以设置文字
// textView.textLayout = textLayout;
OR
// textView.attributedString = attributedString;

textView.frame = CGRectMake(0, 0, textSize.width, textSize.height) textLayout.layoutSize;
[self.view addSubview:textView];

####Highlight

PPTextHighlightRange *highlightRange = [[PPTextHighlightRange alloc] init];
[attributedString pp_setTextHighlightRange:highlightRange inRange:NSMakeRange(0, 5)];

####Border

PPTextBorder *border = [[PPTextBorder alloc] init];
border.fillColor = [UIColor redColor];
[highlightRange setBorder:border];

####Truncated Line

    
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"balabala"];
[attributedString pp_setFont:[UIFont systemFontOfSize: 15.0f]];
[attributedString pp_setColor:[UIColor blackColor]];
    
PPTextLayout *textLayout = [PPTextLayout new];
textLayout.attributedString = attributedString;
textLayout.numberOfLines = 5;
textLayout.maxSize = maxSize;
    
PPTextView *textView = [[PPTextView alloc] init];
textView.textLayout = textLayout;
textView.size = textLayout.layoutSize;
textView.left = 12.0f;
textView.top = 76.0f;
[self.view addSubview:textView];

Text Renderer DEBUG

[PPTextRenderer setDebugModeEnabled:YES];

灰色区域表示绘制的最大 frame,黄色区域表示文字的真实 frame,红线表示 Base line ###PPImageView 高性能圆角图片,自带缓存和下载图片,也支持SDWebImage。

#Installation with CocoaPods ###Podfile 暂时没有上传,等基本完成和测试之后再提交

pod 'PPAsyncDrawingKit'

#Licenses All source code is licensed under the MIT License.

ppasyncdrawingkit's People

Contributors

yizhi996 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.