我們可以通過改變GMUDefaultClusterIconGenerator
類的一種方法管理。
在GMUDefaultClusterIconGenerator.m
取代下面的方法,
- (UIImage *)iconForSize:(NSUInteger)size {
NSUInteger bucketIndex = [self bucketIndexForSize:size];
NSString *text;
// If size is smaller to first bucket size, use the size as is otherwise round it down to the
// nearest bucket to limit the number of cluster icons we need to generate.
if (size < _buckets[0].unsignedLongValue) {
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
} else {
text = [NSString stringWithFormat:@"%ld+", _buckets[bucketIndex].unsignedLongValue];
}
if (_backgroundImages != nil) {
UIImage *image = _backgroundImages[bucketIndex];
return [self iconForText:text withBaseImage:image];
}
return [self iconForText:text withBucketIndex:bucketIndex];
}
與
- (UIImage *)iconForSize:(NSUInteger)size {
NSUInteger bucketIndex = [self bucketIndexForSize:size];
NSString *text;
// If size is smaller to first bucket size, use the size as is otherwise round it down to the
// nearest bucket to limit the number of cluster icons we need to generate.
if (size < _buckets[0].unsignedLongValue) {
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
}
else{
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
}
if (_backgroundImages != nil) {
UIImage *image = _backgroundImages[bucketIndex];
return [self iconForText:text withBaseImage:image];
}
return [self iconForText:text withBucketIndex:bucketIndex];
}
我做了什麼時,我只是改變其他部分,並設置text
爲exact number
而不是string with +
!
真棒解決方案!我想知道它是否會損害表演? –
不,我還沒有打上任何性能問題!!!! – Lion