조회 수 4088 추천 수 0 댓글 0
Atachment
첨부 '3'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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
번호 분류 제목 글쓴이 날짜 조회 수
293 System/OS [mac] SVN 1.8 업데이트 방법 hooni 2013.09.24 14694
292 System/OS [mac] VirtualBox 실행 스크립트와 bash_profile 설정 file hooni 2020.07.08 1169
291 System/OS [mac] 맥(OSX)에서 NTFS, 윈도우에서 HFS+ 사용하기 file hooni 2014.03.12 5173
290 System/OS [mac] 맥(OSX)에서 root 패스워드 설정하기 hooni 2013.04.23 22595
289 System/OS [mac] 맥OSX에서 NTFS 쓰기 기능 활성화 hooni 2014.03.12 4355
288 System/OS [mac] 맥에서 APM(apache,php,mysql) 구성하기 hooni 2013.04.23 38798
287 System/OS [mac] 맥에서 기본 실행 앱 변경하기 file hooni 2018.03.02 1951
286 System/OS [mac] 맥에서 슬립(잠자기) 모드 진입을 막는 방법~ hooni 2013.10.10 31274
285 System/OS [mac] 컨텍스트(Context) 메뉴 "다음으로 열기" 내용 정리 hooni 2013.07.10 18888
284 System/OS [mac] 패키지 매니저, MacPort hooni 2015.01.03 1111
283 System/OS [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 file hooni 2015.01.04 2286
282 Develop [matlab] ZigZag-Scanning (2-D Array) file hooni 2016.10.15 2100
281 Develop [matlab] 정보은닉 스테가노그래피(Steganography) 수업 file hooni 2016.10.03 780
280 Develop [maven] Mac OS에 메이븐(maven) 설치하기 file hooni 2015.01.21 1210
279 System/OS [ms-sql] 서브스트링(substring), 프로시저(SP) 작성 예제 hooni 2013.04.23 41379
278 System/OS [ms-sql] 프로시져 예제.. file hooni 2013.04.23 13486
Board Pagination Prev 1 ... 54 55 56 57 58 ... 74 Next
/ 74