본문 바로가기
728x90

iOS/iOS78

UIPickerView pickerview 항목 2개 이상 만들기 NSMutableArray * yearArr; NSMutableArray * monthArr; // 열 개수 - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 2; } // 열 데이터 갯수 - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { if (component == 0) { return [yearArr count]; } else { return [monthArr count]; } } // 행 높이 - (CGFloat)pickerView:(UIP.. 2022. 11. 2.
navigation stack에서 특정 VC 삭제 NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers]; for (int i = 0; i < [navigationArray count]; i++) { if ([[navigationArray objectAtIndex:i] isKindOfClass:[지우려는VC class]]) { [navigationArray removeObjectAtIndex: [navigationArray count] - ([navigationArray count] - i)]; } } self.navigationController.viewControllers = navigationArr.. 2022. 11. 2.
UIScrollView 스크롤을 최하단으로 이동 [self.scroll setContentSize:CGSizeMake(self.view.frame.size.width, self.scroll.frame.size.height + keyboardHeight)]; CGPoint bottom = CGPointMake(0, self.scroll.contentSize.height - self.view.bounds.size.height + self.scroll.contentInset.bottom); if (bottom.y > 0) { [self.scroll setContentOffset:bottom animated:YES]; } 2022. 11. 1.
UISegmentedControl 선택 상태에 따라 세그타이틀 컬러 변경 - (IBAction)segmentedControlTap:(UISegmentedControl *)sender { NSDictionary *select = @{NSForegroundColorAttributeName: UIColor.redColor}; NSDictionary *normal = @{NSForegroundColorAttributeName: UIcolor.blackColor}; [sender setTitleTextAttributes:normal forState:UIControlStateNormal]; [sender setTitleTextAttributes:select forState:UIControlStateSelected]; } 2022. 10. 19.
UITabBar 선택된 아이템 컬러 변경 Tab bar controller의 탭바 선택 - identity Inspector - User Defined Runtime Attributes tintColor = 선택된 아이템 색상 unSelectedItemTintColor = 선택되지 않은 아이템 색상 코드로 title 속성 변경 let baselineOffset = (height - font lineHeight) / 4 let style = NSMutableParagraphStyle() style.maximumLineHeight = height style.minimumLineHeight = height) let tabBarAppearance = UITabBarAppearance () let tabBarItemAppeara.. 2022. 10. 19.
UIscrollView dynamic height 스크롤뷰의 높이를 컨텐츠에 맞게 설정하는 방법! scrollview의 subview의 frame을 'CGRectUnion' 함수를 이용하여 설정할 수 있다. CGRect contentRect = CGRectZero; for (UIView *view in self.scroll.subviews) { for (UIView * content in view.subviews) { contentRect = CGRectUnion(contentRect, content.frame); } } self.scroll.contentSize = contentRect.size; 참고 : https://stackoverflow.com/questions/2944294/how-do-i-auto-size-a-uiscrollview-to-f.. 2022. 10. 14.
특정 viewcontroller로 pop 방법1. NSArray * vcStack = self.navigationController.viewControllers; NSInteger index = vcStack.count - 1; while (YES) { index--; UIViewController *vc = [vcStack objectAtIndex:index]; if([vc isKindOfClass:[원하는VC class]]){ [self.navigationController popToViewController:vc animated:YES]; return; } } 방법2. let controllers = self.navigationController?.viewControllers for vc in controllers! { if vc is A.. 2022. 10. 13.
Animation 밑에서 천천히 올라오는 팝업창 구현 스토리보드 오토레이아웃 제약을 이용하여 구현하는 방식 1. 올라올 뷰를 뷰컨트롤러 화면보다 밑으로 배치 2. 팝업창의 bottom 제약조건을 outlet으로 연결 3. superView는 배경색을 clear Color로 설정 4. 팝업 애니메이션 코드 작성 superView는 투명한 검정색으로 팝업뷰(datePickerBackViewBottom)는 밑에서 위로 올라오도록 레이아웃 값 변경 func show() { UIView.animate(withDuration: 0.3, animations: { self.view.backgroundColor = UIColor(displayP3Red: 0, green: 0, blue: 0, alpha: 0.6) }) UIView.ani.. 2022. 10. 11.
지도앱 URL Scheme 카카오맵 : https://apis.map.kakao.com/ios/guide/#urlscheme_open_mapapp 카카오앱에 원하는 주소로 바로 이동하여 실행 시키고 싶다면, '좌표로 이동' 부분의 URL Scheme을 이용하면 된다. kakaomap://look?p=좌표LAT,좌표LNG 카카오네비 : https://developers.kakao.com/docs/latest/ko/kakaonavi/ios 카카오네비는 다른앱과 달리 URL Scheme으로 열리지 않아서 API연결하여 사용해야 한다. -> 참고: https://devtalk.kakao.com/t/ios-kakao-navi-url-scheme/109747/2 네이버지도 : https://guide.ncloud-docs.com/docs/n.. 2022. 10. 5.