Latest 1.0.3
Homepage https://github.com/DSKcpp/PPAsyncDrawingKit
License MIT
Platforms ios 7.0, requires ARC
Frameworks CoreText
Authors

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.

Latest podspec

{
    "name": "PPAsyncDrawingKit",
    "version": "1.0.3",
    "platforms": {
        "ios": "7.0"
    },
    "license": "MIT",
    "summary": "iOS asynchronously drawing view Kit.",
    "homepage": "https://github.com/DSKcpp/PPAsyncDrawingKit",
    "authors": {
        "DSKcpp": "[email protected]"
    },
    "source": {
        "git": "https://github.com/DSKcpp/PPAsyncDrawingKit.git",
        "tag": "1.0.3"
    },
    "description": "This is a kit for asynchronously drawing view, implementation of the ImageView, Label, Button.",
    "source_files": "PPAsyncDrawingKit/PPAsyncDrawingKit/*.{h,m}",
    "requires_arc": true,
    "frameworks": "CoreText"
}

Pin It on Pinterest

Share This