Contents

Views 4049 Comment 0
Atachment
Attachment '3'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

iOS 7 이후부터 UINavigationController의 UINavigationBar에 Custom UIBarButtonItem를 사용하면 여백이 생기는 현상이 발생함.


아래 그림처럼..


# iOS 6 일때

ios6.png


# iOS 7 일때는 아래처럼 왼쪽에 여백이 생김

ios7.png


이런 문제를 아래 코드를 이용해 해결할 수 있음.


# UIButton (Alignment)

- (UIEdgeInsets)alignmentRectInsets {
    UIEdgeInsets insets;
    if (SYSTEM_VERSION_LESS_THAN(@"7.0")) {
        if ([self isLeftButton]) {
            insets = UIEdgeInsetsMake(0, 9.0f, 0, 0);
        } else {
            insets = UIEdgeInsetsMake(0, 0, 0, 9.0f);
        }
    } else {
        insets = UIEdgeInsetsZero;
    }

    return insets;
}

- (BOOL)isLeftButton {
    //return self.frame.origin.x) < (self.superview.frame.size.width / 2);
    CGFloat mid = self.frame.origin.x - self.frame.size.width/2;
    return mid < (self.superview.frame.size.width / 2);
}


위의 코드를 수정해서 완성본을 업로드 해두었음..

- 압축 파일 내용

ver1 : 생성자에서 UIButton의 좌우 위치를 지정함 (레거시 코드에 적용시 alloc init 부분 수정 발생)

ver2 : 생성자 없이 UIButton 자신의 좌표로 좌우를 판단해서 알아서 적용 (레거시 코드 바로 적용)


[출처] http://stackoverflow.com/questions/18861201/uibarbuttonitem-with-custom-view-not-properly-aligned-on-ios-7-when-used-as-left


?

List of Articles
No. Category Subject Author Date Views
1173 [ios] 인앱결제 & 오토레이아웃 관련 강좌 secret hooni 2013.11.14 0
1172 PPT 네오웹 세미나 자료~ secret hooni 2013.05.28 0
1171 Develop [iphone] PerfectlyClear 보정솔루션 최신.. secret hooni 2013.05.28 0
1170 PPT [doc] BHO관련 발표 자료(디펜스에 쓸꺼) secret hooni 2013.05.28 0
1169 Develop [ios] IB 없이 개발하기 (html) secret hooni 2013.05.31 0
1168 Develop [ios] 스터디 자료 (from 종길M) secret hooni 2013.06.04 0
1167 Develop [ios] 패스(path) 앱 메뉴 스타일 secret hooni 2013.06.11 0
1166 Etc 영어 아주 쉬운 영작문 강의 01~60 secret hooni 2013.06.25 0
1165 Etc 영어 관련 토렌트 secret hooni 2013.06.25 0
1164 Develop 이어서 작업할 내용~ secret hooni 2013.11.21 0
1163 Develop [ios] APNS 샘플 코드.. secret hooni 2013.06.27 0
1162 Develop [ios] 최신 UI 모음.. (나중에 정리할 것) secret hooni 2013.08.09 0
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 98 Next
/ 98