300x250 iOS112 NSMutableArray 중복 제거 NSMutableArray *_userIds = [NSMutableArray new]; for( NSInteger i = 0; i < 3; i++ ) { [_userIds insertObject:@"aaaaaaaaaa" atIndex:i]; } NSOrderedSet *userSet = [[NSOrderedSet alloc] initWithArray:_userIds]; _userIds = [[NSMutableArray alloc] initWithArray:[userSet array]]; 출처 : https://mrkn.tistory.com/337 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. NSString 문자열 생성 NSString * str1 = [NSString new]; NSString * str2 = [[NSString alloc] initWithString:@"안녕안녕"]; 문자열 합치기 NSString * str1 = [NSString new]; str1 = @"반가워"; NSString * str2 = [[NSString alloc] initWithString:@"안녕안녕"]; NSString * str3 = [str1 stringByAppendingString:str2]; // str3 = 반가워안녕안녕 NSString * str1 = @"안녕"; NSString * str2 = [str1 stringByAppendingString:@" 반가워"]; // 안녕 반가워 문자열 비교 NSStr.. 2022. 10. 27. 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. 이전 1 ··· 3 4 5 6 7 8 9 ··· 13 다음 300x250