[iOS] static library에서 image 사용하기 [iOS] static library 에서 image 사용하기 bundle에 이미지가 있다는 가정 하에 사용하는 방법이다. 기존에는 UIImage *image = [UIImage imageNamed:@"imageName"]; 식이었다면 UIImage *image = [UIImage imageNamed:@"BundleName.bundle/imageName"]; 식으로 번들 이름을 추가해서 사용하면 이미지가 제대로 뜬다! iOS/Swift + Objective-c 2017.09.05
[IOS] status bar text color 변경 [IOS] status bar text color 변경법 프로젝트 TARGETS > General > Deployment Info > Status Bar Style > Light 로 변경 iOS/Swift + Objective-c 2017.08.11
[iOS objective-c] indicator 사용하기 [iOS objective-c] indicator 사용하기 1. 만들 때 UIView *indicatorView; UIActivityIndicatorView *activityIndicator; UILabel *labelLoading; indicatorView = [[UIView alloc]initWithFrame:CGRectMake([UIApplication sharedApplication].keyWindow.frame.size.width/2-50, [UIApplication sharedApplication].keyWindow.frame.size.height/2-30 , 100, 100)]; indicatorView.backgroundColor = [[UIColor blackColor]colorWithA.. iOS/Swift + Objective-c 2017.04.27
[objective c] NSString contains string [iOS Objective c] NSString contains string NSString *string = @"hello bla bla"; if ([string rangeOfString:@"bla"].location == NSNotFound) { NSLog(@"string does not contain bla"); } else { NSLog(@"string contains bla!"); }And if you're on iOS 8 or OS X Yosemite, you can now do: (*NOTE: This WILL crash your app if this code is called on an iOS7 device).NSString *string = @"hello bla blah"; if ([st.. iOS/Swift + Objective-c 2017.04.21
[iOS Objective c] 화면 흔들기 (view shake) 구현 [iOS Objective c] 화면 흔들기 (view shake) 구현 setDuration : 애니메이션 실행 시간setRepeatCount : 애니메이션 실행 횟수 setFromValue : 애니메이션 시작 위치setToValue : 애니메이션 끝 위치 다음 코드는 0.05초 동안 좌우로 20.0f 씩 4번 흔드는 애니메이션 CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; [animation setDuration:0.05]; [animation setRepeatCount:4]; [animation setAutoreverses:YES]; [animation setFromValue:[NSValue val.. iOS/Swift + Objective-c 2017.03.31
[iOS Objective c] 진동 구현 [iOS Objective c] 진동 구현하기 1. Framework 에서 AudioToolbox.framework 를 import 해준다. 2. 헤더 파일에 다음 코드를 추가한다.#import 3. 진동을 사용할 부분에 다음 코드를 추가한다.AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 끝 iOS/Swift + Objective-c 2017.03.31
[iOS] NSMutableArray 배열 순서 섞기 [iOS] NSMutableArray 배열 순서 섞기 (랜덤으로 섞기) [Objective-c] for (int i=0; i < [arrTestA count]; i++) { int random = arc4random() % [arrTestA count]; [arrTestA exchangeObjectAtIndex:random withObjectAtIndex:i]; } 만약 특정 인덱스는 섞으면 안될 경우 아래 코드를 추가해주자. if (random == 5 || i == 5) { continue; } [Swift] extension Array { mutating func suffle() { if count < 2 { return } for i in 0 ..< (count - 1) { let j = Int(.. iOS/Swift + Objective-c 2017.03.30
[Objective-c] KeyChain example [Objective-c] KeyChain example KeychainIf you’re a developer, you know you will, you know you will have to store sensitive data in your app sooner or later. Storing sensitive data in NSUserDefaults is a big no-no, so you just can’t store sensitive data there. Instead, just like OS X, iOS provides a keychain your app can use to store all sorts of sensitive data. The keychain is they key place to .. iOS/Swift + Objective-c 2017.03.28
[Objective-C] alloc, init 메서드 ClassA* a = [ClassA alloc]; alloc은 allocate(할당하다)의 줄임말이다. 새로운 클래스에 메모리 공간을 할당하는 것이다. 클래스에 alloc 메세지를 보내, 그 클래스의 새로운 인스턴스를 받는다. alloc 메서드는 객체의 모든 인스턴스 변수를 0으로 초기화한다. 그러나 이것으로 객체가 사용하기에 충분히 초기화되었다고 볼 수는 없다. 따라서 객체를 생성(allocate, 메모리에 할당)한 후, 초기화(initialize)해 주어야 한다. 이것은 다음 명령문으로 수행할 수 있다. a = [a init]; init 메서드는 클래스의 인스턴스를 초기화한다. a 변수에 init 메시지를 보내는 것에 주목하자. 이것은 클래스가 아니라 특정한 ClassA 객체를 초기화하는 것을 뜻한다.. iOS/Swift + Objective-c 2017.02.03