blog.visualp.com
[self.navigationController popViewControllerAnimated:YES];
self는 NaviationController 입니다.
NSString *string1 = @"This is";
NSString *string2 = @" a test.";
NSString *string3 = [string1 stringByAppendingString:string2];
// 이제 string3는 @"This is a test." string1과 string2는 변하지 않는다.
NSString *string1 = @"This is";
NSString *string2 = @" a test.";
string1 = [string1 stringByAppendingString:string2];
// 이제 string1은 @"This is a test."
NSMutableString *string1 = @"This is";
NSString *string2 = @" a test.";
[string1 appendString:string2];
// 이제 string1은 @"This is a test."
네비게이션 바 자체에 폰트를 지정하거나 글씨의 크기를 지정하는 방법이 있는 것 같지는 않다.
하지만 여러가지 방법을 이용해서 폰트의 지정 및 글씨의 크기를 변경해 사용할 수 있다.
직접 사용해본 코드로 잘 동작하는 것을 확인할 수 있었다.
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont fontWithName:@"Helvetica-Bold" size: 15.0];
// Optional - label.text = @"NavLabel";
[label setBackgroundColor:[UIColor clearColor]];
[label setTextColor:[UIColor whiteColor]];
[label setText:@"원하는 타이틀을 지정하세요."];
[label sizeToFit];
[self.navigationController.navigationBar.topItem setTitleView:label];
[label release];
또 아래와 같이 하면 메인 타이틀 하위에 subtitle 을 넣는 효과까지 낼 수 있다.
( 사실 레이블을 두개 붙이는 것이지만..)
- (void)SetNavigationTitle:(NSString*)title subtitle:(NSString*)subTitle
{
if (subtitle == nil) {
self.navigationItem.titleView = nil;
self.navigationItem.title = title;
return;
}
// set the default title anyway, so the next view controllers will have the correct text on their "back" button
self.navigationItem.title = title;
#define LEFT_OFFSET 15
// Replace titleView
CGRect headerTitleSubtitleFrame = CGRectMake(LEFT_OFFSET, 0, 200, 44);
UIView* _headerTitleSubtitleView = [[UILabel alloc] initWithFrame:headerTitleSubtitleFrame];
_headerTitleSubtitleView.backgroundColor = [UIColor clearColor];
_headerTitleSubtitleView.autoresizesSubviews = YES;
CGRect titleFrame = CGRectMake(LEFT_OFFSET, 2, 160, 24);
UILabel *titleView = [[UILabel alloc] initWithFrame:titleFrame];
titleView.backgroundColor = [UIColor clearColor];
titleView.font = [UIFont boldSystemFontOfSize:20];
titleView.textAlignment = UITextAlignmentCenter;
titleView.textColor = [UIColor whiteColor];
titleView.shadowColor = [UIColor darkGrayColor];
titleView.shadowOffset = CGSizeMake(0, -1);
titleView.text = title;
titleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:titleView];
[titleView release];
CGRect subtitleFrame = CGRectMake(LEFT_OFFSET, 24, 160, 44-24);
UILabel *subtitleView = [[UILabel alloc] initWithFrame:subtitleFrame];
subtitleView.backgroundColor = [UIColor clearColor];
subtitleView.font = [UIFont boldSystemFontOfSize:13];
subtitleView.textAlignment = UITextAlignmentCenter;
subtitleView.textColor = [UIColor whiteColor];
subtitleView.shadowColor = [UIColor darkGrayColor];
subtitleView.shadowOffset = CGSizeMake(0, -1);
subtitleView.text = subTitle;
subtitleView.adjustsFontSizeToFitWidth = YES;
[_headerTitleSubtitleView addSubview:subtitleView];
[subtitleView release];
self.navigationItem.titleView = _headerTitleSubtitleView;
[_headerTitleSubtitleView release];
}
[출처] NavigationBar 의 글씨 크기 변경하기..|작성자 홍길동
| |||||
|
// UILabel 생성하기 UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 40, 20)]; // label에 태그 넣기 aLabel.tag = 1; // 글자쓰기 aLabel.text = @ "Hello World" ; // 라벨을 뷰에 올리기 [self.view addSubview:aLabel]; |
/ 메소드
- (void) handleTimer: (NSTimer *) timer
{
// 수행 작업
}
// 타이머 생성
NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval: 0.03f target: self selector: @selector(handleTimer:)
userInfo: nil repeats: YES];
// 타이머 해제
[tmier invalidate];
+initialize 메소드는 클래스 메소드로서 클래스 객체를 초기화
-init 메소드는 인스턴스 메소드로서 인스턴스 객체를 초기화