【问题标题】:Change size of legend in core plot?更改核心情节中图例的大小?
【发布时间】:2012-08-23 02:34:33
【问题描述】:

我有一个带有相应图例的饼图。如何更改图例框的大小? (使包括文本、颜色框和框架在内的所有内容变小)。

请注意,我正在为 OSX 而不是 iOS 构建应用程序。

【问题讨论】:

    标签: objective-c macos cocoa core-plot


    【解决方案1】:

    如果您只是将CPTLegend 设置为较小的文本样式,则所有内容都将根据要求调整大小。因此,对于您的CPTGraph,您将要执行以下操作:

    CPMutableTTextStyle *mySmallerTextStyle = [[[CPTMutableTextStyle alloc] init] autorelease];
    [textStyle setFontName:fontName];
    [textStyle setColor:color];
    
    //This is the important property for your needs
    [textStyle setFontSize:5];
    
    //Set this up with your graph
    [graph setLegend:[CPTLegend legendWithGraph:graph]];
    [[graph legend] setTextStyle:(CPTTextStyle *)mySmallerTextStyle];
    

    CorePlot 论坛上有一个discussion 与此相关。

    【讨论】: