手机APP开发 2017-02-03
NSArray *tmpArray = [self.zhiBiaoArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"month == '%@'", month]]];
NSString *regex = @"^[0-9]*$"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self matches %@",regex]; return [predicate evaluateWithObject:text];
根据数据中的对象的属性排序
tmpArray = [tmpArray sortedArrayUsingComparator:^NSComparisonResult(SuiFangItem *obj1, SuiFangItem *obj2) { return [obj1.SUBDATE compare:obj2.SUBDATE] == NSOrderedAscending;}];
经典代码,标签 for 循环排序设置标签的 xy
for (NSInteger i = 0; i < tagBtnArray.count; i ++) { UIButton *tagBtn = tagBtnArray[i]; if (i == 0) { tagBtn.fd_x = 0; tagBtn.fd_y = 0; } else { UIButton *previousBtn = tagBtnArray[i -1]; tagBtn.fd_x = CGRectGetMaxX(previousBtn.frame) + 10; tagBtn.fd_y = previousBtn.fd_y; if ((tagViewW - tagBtn.fd_x) < tagBtn.fd_width) {tagBtn.fd_x = 0; tagBtn.fd_y = CGRectGetMaxY(previousBtn.frame) + 10; } } }解析 xml 值格式 的数据,xml 属性格式 的可使用系统的
服务器返回一堆带有月份的数据,服务器并未做按月分组,本地实现按月分组
// 获得数据中存在的月份,共有哪几个月份 NSMutableArray *monthArray = [NSMutableArray array]; ZhiBiaoItem *firstItem = self.zhiBiaoArray[0]; [monthArray addObject:firstItem.month]; for (NSInteger i = 1; i < self.zhiBiaoArray.count; i ++) { ZhiBiaoItem *item = self.zhiBiaoArray[i]; if (![item.month isEqualToString:firstItem.month]) { if ([monthArray containsObject:item.month]) { continue; } [monthArray addObject:item.month]; } } self.monthArray = monthArray; // 根据月份进行分组 NSMutableDictionary *resultDict = [NSMutableDictionary dictionary]; for (NSString *month in monthArray) { NSArray *tmpArray = [self.zhiBiaoArray filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"month == '%@'", month]]]; [resultDict setObject:tmpArray forKey:month]; } self.resultDict = resultDict;使用 AFN 配置服务器自己创建的 https 证书的 https
使用 AFN 忽略所有 https 证书、不检测域名的策略
AFSecurityPolicy *secPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]; secPolicy.allowInvalidCertificates = YES; secPolicy.validatesDomainName = NO; _mgr.securityPolicy = secPolicy;
配置 AFN 本地 https证书? 不清楚如何配置
PNChart 修改 节点label 的大小,在源码中修改
- (CATextLayer *)createPointLabelFor:(CGFloat)grade pointCenter:(CGPoint)pointCenter width:(CGFloat)width withChartData:(PNLineChartData *)chartData { CATextLayer *textLayer = [[CATextLayer alloc] init]; [textLayer setAlignmentMode:kCAAlignmentCenter]; [textLayer setForegroundColor:[chartData.pointLabelColor CGColor]]; [textLayer setBackgroundColor:[[[UIColor whiteColor] colorWithAlphaComponent:0.8] CGColor]]; [textLayer setCornerRadius:textLayer.fontSize / 8.0]; if (chartData.pointLabelFont != nil) { [textLayer setFont:(__bridge CFTypeRef) (chartData.pointLabelFont)]; textLayer.fontSize = [chartData.pointLabelFont pointSize]; } CGFloat textHeight = textLayer.fontSize * 1.1; CGFloat textWidth = width * 7; CGFloat textStartPosY; }
- (void)setXLabels:(NSArray *)xLabels withWidth:(CGFloat)width { }
- (void)setYLabels { PNChartLabel *minLabel = [[PNChartLabel alloc] initWithFrame:CGRectMake(0.0, (NSInteger) _chartCavanHeight - 10, (NSInteger) _chartMarginBottom, (NSInteger) _yLabelHeight)]; CGRect labelFrame = CGRectMake(0.0, (NSInteger) (_chartCavanHeight + _chartMarginTop - index * yStepHeight) -10, }
- (void)calculateChartPath:(NSMutableArray *)chartPath andPointsPath:(NSMutableArray *)pointsPath andPathKeyPoints:(NSMutableArray *)pathPoints andPathStartEndPoints:(NSMutableArray *)pointsOfPath { int x = i * _xLabelWidth + _chartMarginLeft + _xLabelWidth / 2.0 + 6; }