iOS開源 - 數學,物理,化學公式以及圖形渲染庫

iqrhtv6594 8年前發布 | 9K 次閱讀 iOS開發 移動開發

Latex

latex是目前比較全面用于將數學,物理,化學公式轉換成格式化字符的形式,現在也是各大主流教育類app的主要數據存儲形式.

Katex

Katex是基于js實現的渲染Latex代碼的庫,據稱是目前渲染效率最好,性能最優的公式渲染引擎.

MathKit

基于Katex渲染庫,并用YYText進行異步排版,完美實現了理科公式非數據化數據的處理以及視圖展示.MathKit github鏈接

MathKit強在哪?

  • 強勁的渲染性能
  • 非常簡單的代碼
  • 快速集成
  • 極少的依賴庫
  • 一個類,一個屬性,一句話解決理科公式渲染

    如何使用

#import "MathSubjectView.h"
NSString*str =@"4.<math>\\displaystyle= \\frac{k(k+1)}{2}+k+1</math>這個大家知道是什么嗎?請寫出答案吧";
MathSubjectView*subject = [[MathSubjectViewalloc]initWithFrame:CGRectMake(10,100,self.view.bounds.size.width-20,0)];
subject.font= [UIFontsystemFontOfSize:12];
subject.testStr= str;
[self.viewaddSubview:subject];

舉個例子

iOS開源 - 數學,物理,化學公式以及圖形渲染庫

 

GitHub介紹

MathKit

What MathKit can do?

  • It will render you your math, physics, chemistry or any science formula,Geometric graphics and pictures, as well as general text.

  • MathKit used by the rendering engine from the current fastest performance of the best JavaScript mathematical formula rendering engine

  • MathKit the mathematical formula derived from the code is very simple and very easy to store the Latex code

Based on this, we believe that it will become the most popular science formula and graphics rendering Library

Why you need MathKit?

  • Strong rendering performance
  • Very simple code
  • Fast integration
  • Minimal dependency Library

Usage

  1. Download all the files in the MathKit subdirectory.
  2. Add the source files to your Xcode project.
  3. Link with required frameworks:
  4. Import MathSubjectView.h.
  5. Initialization of an instance object, and give the testStr attribute assignment, where the object will be copied to the mixture of arbitrary science formulas and pictures of the string.
    Note: Here's the formula in the string need to use a tag similar to <math></math> wrapped up, and the picture will need to use a tag similar to <image></image> wrapped up, so as to be recognized
  6. Add the instance object to your view.

If you still do not know how to use it, then download the code to see it, the package has my prepared sample demo.


 

 

 

 本文由用戶 iqrhtv6594 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!