相关疑难解决方法(0)

如何使用CoreText在富文本中绘制图像?(IOS)

我可以使用Core Text绘制富文本,问题是将图像与文本一起流动.(iOS SDK 4.1)

我试着绘制某种富文本.问题是设计师在文本中放置了许多图标.所以我要绘制的文字是这样的:

Here is a word <an icon image>, and another words.
The image(<another icon>) should be placed like a glyph.
It's part of text, not an example.
Run Code Online (Sandbox Code Playgroud)

<icon>是图像.(这不是代码.只是一个例子.)

我可以通过手动布局所有这些来绘制它,但是保持复杂的文本布局行为太难了.所以我找到了一种用Core Text绘制它的方法.

text image core-text

9
推荐指数
1
解决办法
6825
查看次数

CTFramesetterSuggestFrameSizeWithConstraints,剪切属性返回零高度

H!我正在编写带有子视图剪辑功能的te​​xtview.我们的想法是让所有文字都围绕所有子视图绘制.问题是获得它的内容高度.

由于缺少文档,我决定CTFramesetterSuggestFrameSizeWithConstraints的属性字典与CTFramesetterCreateFrame的属性字典相同.

这是我的剪切路径代码:

-(CFDictionaryRef)clippingPathsDictionary{
if(self.subviews.count==0)return NULL;

NSMutableArray *pathsArray = [[NSMutableArray alloc] init];

CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformScale(transform, 1, -1);
transform = CGAffineTransformTranslate(transform, 0, -self.bounds.size.height);

for (int i=0; i<self.subviews.count; i++) {
    UIView *clippingView = self.subviews[i];
    CGPathRef clipPath = CGPathCreateWithRect(clippingView.frame, &transform);

    NSDictionary *clippingPathDictionary = [NSDictionary dictionaryWithObject:(__bridge id)(clipPath) forKey:(__bridge NSString *)kCTFramePathClippingPathAttributeName];
    [pathsArray addObject:clippingPathDictionary];
    CFRelease(clipPath);
}


int eFrameWidth=0;
CFNumberRef frameWidth = CFNumberCreate(NULL, kCFNumberNSIntegerType, &eFrameWidth);

int eFillRule = kCTFramePathFillEvenOdd;
CFNumberRef fillRule = CFNumberCreate(NULL, kCFNumberNSIntegerType, &eFillRule);

int eProgression = kCTFrameProgressionTopToBottom;
CFNumberRef progression = CFNumberCreate(NULL, …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c core-text ios

3
推荐指数
1
解决办法
2268
查看次数

标签 统计

core-text ×2

cocoa-touch ×1

image ×1

ios ×1

objective-c ×1

text ×1