最近閑來無事,準(zhǔn)備研究研究TextKit.
TextKit是ios7 新推出的技術(shù),在Core Text之上新增了多項功能,目的是為了讓開發(fā)人員能夠輕松的渲染和處理帶屬性的字符串
先來一發(fā)簡單地 排除路徑
- 排除路徑:讓文本沿著內(nèi)嵌的圖像
UIImageView或者View饒著排
- 要制定排除路徑首先要創(chuàng)建一個排除區(qū)域的 貝塞爾曲線
UIBezierPath。 - 然后把
textView的textContainer的屬性exclusion設(shè)置為一個排除區(qū)域數(shù)組
廢話不多說 直接上代碼
//設(shè)置貝塞爾曲線
UIBezierPath * circlePath=[UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 50, 100, 100)];
UIImageView * imageView=[[UIImageView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];
[imageView setImage:[UIImage imageNamed:@"ab"]];
[self.textView addSubview:imageView];
self.textView.textContainer.exclusionPath=@[circlePath]; //設(shè)定為排除區(qū)域