iOS 개발에서 자주 사용하는 처리 및 기술
디버그할 때 대상의 구체적인 데이터를 출력합니다
모델 클래스에서 debugDescription 메서드 다시 쓰기
debugDescription은 인터럽트가 LLDB po 명령을 통해 대상을 인쇄할 때 호출됩니다. 이 방법은 NSObject 프로토콜의 한 방법입니다. NSObject에서는 기본적으로 실행되었고, 기본값은 인쇄 대상의 주소와 클래스입니다.
모델에서 이 방법을 다시 쓰고 출력 내용을 사용자 정의합니다
- (NSString *)debugDescription {
return [NSString stringWithFormat:@":%@",[self class],&self,@{@"name" : _name,@"age" : _age}];
}
내비게이션 표시줄 투명성
내비게이션 표시줄에 빈 배경 그림 한 장을 주면 된다
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
탐색 모음의 선도 투명하게 만들기
self.navigationController.navigationBar.shadowImage = [UIImage new];
드롭다운 거리에 따라 내비게이션 막대 투명도 조정
[[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 0; // alpha
탐색 모음 배경색 설정
self.navigationBar.barTintColor = [UIColor orangeColor];
전역적으로 navigationBar, Tabbar 스타일 설정
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18]}];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:10]}];
뷰의 모든 하위 뷰 인쇄하기
po [[self view] recursiveDescription]
로드 xib에서 UIView로 변환
UINib *nib = [UINib nibWithNibName:@"XLStockOrdersSectionHeader" bundle:[NSBundle mainBundle]];
UIView *header = (UIView *)[nib instantiateWithOwner:nil options:nil].firstObject;
UIView *header = (UIView *)[[NSBundle mainBundle] loadNibNamed:@"XLStockOrdersSectionHeader" owner:nil options:nil].firstObject;
UINib 및 NSBundle
NSBundle 로드는 항상 로컬에서 xib를 메모리로 읽기
UINib 는 xib 를 로드한 후 메모리에 캐시되며, 다시 xib 를 변경해야 할 때 메모리에서 읽습니다
presentViewController
TestViewController *testVC = [[TestViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:testVC];
[self presentViewController:nav animated:YES completion:nil];
모든 컨트롤러에 아래의 방법을 추가하여 모든 컨트롤러의 소각을 편리하게 감시해야 한다
- (void)dealloc {
#ifdef DEBUG
NSLog(@"dealloc -- %@",[selfclass]);
#endif
}
textfield의placeholder 색상을 설정하는 두 가지 방법
NSAttributedString*attr = [[NSAttributedStringalloc]initWithString:@" "attributes:@{NSBackgroundColorAttributeName:[UIColorwhiteColor]}];
self.phoneNumTextField.attributedPlaceholder= attr;
[self.phoneNumTextFieldsetValue:[UIColorwhiteColor]forKeyPath:@"_placeholderLabel.textColor"];
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.