2016-09-29 16 views

答えて

3

imageView

var exclusionPath = UIBezierPath(rect: CGRect(x: imageView.frame.orgin.x, y: imageView.frame.orgin.y, width: imageView.frame.size.width, height: imageView.frame.size.height)) 
textView.textContainer.exclusionPaths = [exclusionPath] 
textView.addSubview(imageView) 
0

あなたはword'llが文字の後にカットすることを意味NSLineBreakByCharWrappingを使用する必要があります。

textview.textContainer.lineBreakMode = NSLineBreakByCharWrapping; 
+2

...それは

コーディングハッピーを役に立てば幸いblemは改行ではありませんが、それはイメージをカバーしています:) – vladasha

0

UITextViewにあなたはまさにこの方法のような設計を行うことができます追加した後に以下のコードを追加しますCoreText枠組み

import CoreText 

を追加します。私はSwift 3を使用していませんが、構文に従ってそれをフォーマットすることができます。

ここでは、exclusionPathは画像の後にテキストを開始する責任を負い、exclusionPath1はお客様の要件に従って画像の下のテキストを開始します。

マイコード:

let txtView = UITextView(frame: CGRectMake(0, 64, SCREEN_SIZE.width, 150)); 
    self.view.addSubview(txtView); 

    let imageView = UIImageView(frame: CGRectMake(0, 0, 50, 50)); 
    imageView.image = UIImage(named: "icon"); 

    let exclusionPath = UIBezierPath(rect: CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)); 
    let exclusionPath1 = UIBezierPath(rect: CGRectMake(-50, 50, imageView.frame.size.width, imageView.frame.size.height)); 

    txtView.textContainer.exclusionPaths = [exclusionPath, exclusionPath1]; 
    txtView.addSubview(imageView); 

出力:

enter image description here

はプロ

関連する問題