Methods have changed since iOS 7.0. try it
- (CGFloat)charactersOffsetBeforeDayPartOfLabel { NSRange range = [[self stringFromDate:self.currentDate] rangeOfString:[NSString stringWithFormat:@"%i",[self dayFromDate:self.currentDate]]]; NSString *chars = [[self stringFromDate:self.currentDate] substringToIndex:range.location]; NSMutableArray *arrayOfChars = [[NSMutableArray alloc]init]; [chars enumerateSubstringsInRange:NSMakeRange(0, [chars length]) options:(NSStringEnumerationByComposedCharacterSequences) usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) { [arrayOfChars addObject:substring]; }]; CGFloat charsOffsetTotal = 0; for (NSString *i in arrayOfChars){ NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica Neue" size:16.0f]}; charsOffsetTotal += [i sizeWithAttributes:attributes].width; } return charsOffsetTotal; }
source share