小编Ric*_*ick的帖子

将 HTML 转换为 NSAttributedString 时可以设置默认字体吗?

我正在尝试在 UILabel 中显示 HTML,例如

NSString * htmlString = @"Some html string \n <font size=\"13\" color=\"red\">This is some text!</font>";

NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
Run Code Online (Sandbox Code Playgroud)

现在我得到了一个属性字符串

attrStr 的打印说明: 一些 html 字符串

{

...

NSFont = "<UICTFont: 0x7f8240d7c310> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; **font-size: 12.00pt**";

}
Run Code Online (Sandbox Code Playgroud)

这是一些文字!

{

...
NSFont = "<UICTFont: 0x7f8240d7aff0> font-family: \"Times New Roman\"; font-weight: normal; font-style: normal; **font-size: 37.00pt**";
}
Run Code Online (Sandbox Code Playgroud)

似乎font-size: 12.00pt是默认大小,我想在不更改 HTML 源代码的情况下更改大小。怎么做?

nsattributedstring ios

7
推荐指数
2
解决办法
2002
查看次数

如何在iOS中绘制平滑曲线的折线图?

我有一些像 (x1,y1), (x2,y2), (x3,y3)...

现在我想绘制一个曲线平滑的图表?

我正在尝试绘制如下

-(void)drawPrices
{
    NSInteger count = self.prices.count;
    
    UIBezierPath *path = [UIBezierPath bezierPath]; 
    path.lineCapStyle = kCGLineCapRound;

    for(int i=0; i<count-1; i++)
    {
        CGPoint controlPoint[2];
        
        CGPoint p = [self pointWithIndex:i inData:self.prices];
        if(i==0)
        {
            [path moveToPoint:p];
        }

        CGPoint nextPoint, previousPoint, m;
        nextPoint = [self pointWithIndex:i+1 inData:self.prices];
        previousPoint = [self pointWithIndex:i-1 inData:self.prices];
        
        if(i > 0) {
            m.x = (nextPoint.x - previousPoint.x) / 2;
            m.y = (nextPoint.y - previousPoint.y) / 2;
        } else {
            m.x = (nextPoint.x - p.x) / 2; …
Run Code Online (Sandbox Code Playgroud)

charts curve ios

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

标签 统计

ios ×2

charts ×1

curve ×1

nsattributedstring ×1