【发布时间】:2014-02-09 00:25:09
【问题描述】:
我有这段代码用于在 x 轴上制作刻度和标签:
CPTAxis *x = axisSet.xAxis;
x.title = @"Hour of Day";
x.titleTextStyle = axisTitleStyle;
x.titleOffset = 15.0f;
x.axisLineStyle = axisLineStyle;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
x.labelTextStyle = axisTextStyle;
x.majorTickLineStyle = axisLineStyle;
x.majorTickLength = 4.0f;
x.tickDirection = CPTSignNegative;
CGFloat dateCount = [timestamps count];
NSMutableSet *xLabels = [NSMutableSet setWithCapacity:dateCount];
NSMutableSet *xLocations = [NSMutableSet setWithCapacity:dateCount];
NSInteger i = 0;
for (NSString *date in timestampStrings) {
CPTAxisLabel *label = [[CPTAxisLabel alloc] initWithText:date textStyle:x.labelTextStyle];
CGFloat location = i++;
label.tickLocation = CPTDecimalFromCGFloat(location);
label.offset = x.majorTickLength;
if (label) {
[xLabels addObject:label];
[xLocations addObject:[NSNumber numberWithFloat:location]];
}
}
x.axisLabels = xLabels;
x.majorTickLocations = xLocations;
我想知道我是否可以扩大每个刻度之间的距离,因为现在它看起来就像一个挤在一起的烂摊子,与点不对齐。有没有办法在每个刻度之间留出更多空间,比如 10 像素?谢谢!
【问题讨论】:
-
如果您仍然面临问题,请告诉我,我会为您提供答案。 #HappyToHelp
-
我很欣赏这种情绪,但这个问题已经解决了。该应用程序已发布!谢谢,哈哈。