iOS/Objective C
-
NSString Email checkiOS/Objective C 2017. 1. 3. 11:39
- (BOOL)checkEmail { const char *tmp = [self cStringUsingEncoding:NSUTF8StringEncoding]; if (self.length != strlen(tmp)) { return NO; } //이메일 형식 문법으로 했는지 체크한다 NSString *check = @"([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)(\\.[0-9a-zA-Z_-]+){1,2}"; NSRange match = [self rangeOfString:check options:NSRegularExpressionSearch]; if (NSNotFound == match.location) { return NO; } return YES; }
-
NSString 천단위 , 붙여주기 (돈)iOS/Objective C 2017. 1. 3. 11:24
+ (NSString*) moneyLine:(NSString*)string { NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setGroupingSeparator:@","]; [numberFormatter setGroupingSize:3]; [numberFormatter setUsesGroupingSeparator:YES]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; NSString *theString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:string..
-
NSString x글자 이후 ...처리 truncate tailiOS/Objective C 2016. 12. 26. 12:43
출처 : http://stackoverflow.com/questions/2952298/how-can-i-truncate-an-nsstring-to-a-set-length //범위설정. MIN스트링의 글자, 9몇글자 부터 ... 할껀지NSRange stringRange = {0, MIN([STRING length], 9)}; stringRange = [STRING rangeOfComposedCharacterSequencesForRange:stringRange]; //...처리 NSString *shortString = [NSString stringWithFormat:@"%@...", [STRING substringWithRange:stringRange]]; NSString *str = [NSString s..
-
NSString UILabel 자간iOS/Objective C 2016. 2. 4. 16:05
- (void) setLetterSpace:(UILabel*)label { //글자 세팅 NSString* str = @"Hello World"; CGFloat number = 10.0f; NSMutableAttributedString* attstr = [[NSMutableAttributedString alloc] initWithString:str]; [attstr addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:number] range:NSMakeRange(0, attstr.length)]; [label setAttributedText:attstr]; }
-
NSString UILabel 밑줄 긋기iOS/Objective C 2016. 2. 4. 16:00
- (void) setUnderLine:(UILabel*)label{ //글자 세팅 NSString* str = @"Hello World"; NSMutableAttributedString* attStr = [[NSMutableAttributedString alloc] initWithString:str]; NSRange range1 = [str rangeOfString:@"Hello"]; //밑줄 긋기 [attStr addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle), NSUnderlineColorAttributeName:[UIColor greenColor]} range:range1]; [label setAttributedText..
-
NSString UILabel 두줄 취소선iOS/Objective C 2016. 2. 4. 15:54
- (void) setLine:(UILabel*)label { //글자 세팅 NSString* str = @"Hello World"; NSMutableAttributedString* attStr = [[NSMutableAttributedString alloc] initWithString:str]; NSRange range1 = [str rangeOfString:@"Hello"]; //취소선 긋기 [attStr addAttributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleDouble), NSStrikethroughColorAttributeName:[UIColor redColor]} range:range1]; [label setAttributedT..
-
NSString UILabel 한줄 취소선iOS/Objective C 2016. 2. 4. 15:51
- (void) setLine:(UILabel*)label { //글자 세팅 NSString* str = @"Hello World"; NSMutableAttributedString* attStr = [[NSMutableAttributedString alloc] initWithString:str]; NSRange range1 = [str rangeOfString:@"Hello"];//범위 //취소선 긋기 [attStr addAttributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle), NSStrikethroughColorAttributeName:[UIColor redColor]} range:range1]; [label setAttribu..
-
NSString UILabel 일부 문자열 그림자 설정iOS/Objective C 2015. 12. 23. 10:56
- (void) setTextShadow:(UILabel*)label { //테스트용 문자열 NSString* text = @"hello world!!!"; //문자열 설정 NSMutableAttributedString* att = [[NSMutableAttributedString alloc] initWithString:text]; //변화시킬 범위를 설정 NSRange range = [text rangeOfString:@"hello"]; //그림자 NSShadow* shadow = [[NSShadow alloc] init]; //그림자 색 설정 [shadow setShadowColor:[UIColor blueColor]]; //그라데이션 반경 설정 [shadow setShadowBlurRadius:4...