Contents

Views 4099 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
873 Develop [c] 달팽이 배열? 인지 먼지.. ㅋㅋ hooni 2013.04.23 7151
872 System/OS 무선 인증 서버.. 김도.. ㅋㅋ file hooni 2013.04.23 17692
871 Develop [c] 패킷 유량/프로토콜 통계 모니터링.. file hooni 2013.04.23 8403
870 System/OS [linux] X환경 GNOME에서 KDE로 바꾸는 법.. hooni 2013.04.23 12416
869 Develop [c] 간단한 소켓 프로그래밍 샘플 file hooni 2013.04.23 8187
868 Develop [c] 도메인 소켓(Unix Domain Socket) UDP file hooni 2013.04.23 9314
867 Develop [c] 다중연결 서버 만들기 #1 - fork() 사용 file hooni 2013.04.23 12948
866 Develop [c] 다중연결 서버 만들기 #2 - select() 사용 file hooni 2013.04.23 9378
865 Develop [c] 다중연결 서버 만들기 #3 - poll() 사용 file hooni 2013.04.23 6369
864 Develop [c] 다중연결 서버 만들기 #4 - thread 사용 file hooni 2013.04.23 23750
863 Develop [c] selec()를 이용한 입출력 다중화 file hooni 2013.04.23 8272
862 Develop [c] alarm()함수 설명과 간단한 예제 file hooni 2013.04.23 6704
Board Pagination Prev 1 ... 21 22 23 24 25 26 27 28 29 30 ... 98 Next
/ 98