最近閑來(lái)無(wú)事泳赋,準(zhǔn)備研究研究TextKit
.
TextKit
是ios7 新推出的技術(shù),在Core Text
之上新增了多項(xiàng)功能肪康,目的是為了讓開(kāi)發(fā)人員能夠輕松的渲染和處理帶屬性的字符串
先來(lái)一發(fā)簡(jiǎn)單地 排除路徑
- 排除路徑:讓文本沿著內(nèi)嵌的圖像
UIImageView
或者View
饒著排
- 要制定排除路徑首先要?jiǎng)?chuàng)建一個(gè)排除區(qū)域的 貝塞爾曲線
UIBezierPath
金抡。 - 然后把
textView
的textContainer
的屬性exclusion
設(shè)置為一個(gè)排除區(qū)域數(shù)組
廢話不多說(shuō) 直接上代碼
//設(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ū)域