Contents

Views 5379 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
301 Develop [unix] 날짜 관련 쉘 명령어 (특정일 또는 +-시간, 날짜 계산된 값) hooni 2013.04.23 15854
300 System/OS [linux] 아파치설치/설정 - 사용인증 hooni 2003.04.23 15886
299 System/OS [mac] SVN 1.8 업데이트 방법 hooni 2013.09.24 15888
298 Develop [ios] iOS In App Purchase #1 (코드 구현 전 웹 설정 작업) file hooni 2013.11.20 15909
297 System/OS [perl] 펄 환경 설정해야 할거 ㅋㅋ hooni 2003.04.23 15933
296 Etc [htm] DOM에 대해 ㅎㅎ file hooni 2003.04.23 15948
295 Develop [css] z-index에 설정할 수 있는 최대값? hooni 2013.12.20 15952
294 System/OS [linux] 이기종간의 파일 공유(Samba) hooni 2003.04.23 15953
293 System/OS [linux] 웹로그분석기(webalizer) 설치 & 팁 hooni 2003.04.23 16010
292 Develop [web] URL 인코딩 방법.. 테이블.. ㅋㅋ hooni 2013.04.23 16088
291 System/OS [linux] 특수문자 환경 설정(stty) hooni 2003.04.23 16117
290 Develop [unix] 로그파일 정리 쉘스크립트 hooni 2014.02.19 16120
Board Pagination Prev 1 ... 69 70 71 72 73 74 75 76 77 78 ... 99 Next
/ 99