答案 0 :(得分:3)
添加CoreText
框架
import CoreText
将imageView
添加到UITextView
,
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)
答案 1 :(得分:0)
您应该使用private void launchListFragment(int scope){
getSupportFragmentManager().popBackStack ("detail", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fragment newDetail = ListFragment.newInstance(scope);
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_container, newDetail, "LIST_F_TAG")
.commit();
}
,这意味着在字符后面会删除单词。
NSLineBreakByCharWrapping
答案 2 :(得分:0)
你可以像这样完成设计。虽然我没有使用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);
输出
希望有所帮助
快乐的编码......