2017-10-16 1 views
-1

탐색 표시 줄에 사용자 정의보기로 버튼을 추가했습니다. 그것은 모양이 원형이어야합니다. 다음 코드를 사용 : 제대로 표시되지 않음 iOS 11 용 원형 UI 모양 (Xcode 9)

let infoButton = UIButton(frame: CGRect(x: 0, y: 0, width: 24, height: 24)) 
    infoButton.setTitle("₹", for: .normal) 
    infoButton.layer.cornerRadius = 12 
    infoButton.clipsToBounds = true 
    infoButton.layer.borderWidth = 1.5 

    let infoItem = UIBarButtonItem(customView: infoButton) 
    navigationItem.rightBarButtonItems = [infoItem] 

지금 하지만 아이폰 OS에 적절한 원형을 받고 11 장치까지 잘 작동했다. 아이폰 OS 10 에서 실행되는 장치에서

스냅 샷 : 아이폰 OS 11 에서 실행되는 장치에서

1

스냅 샷 : 당신이 다음 원형보기를 만들려면

enter image description here

답변

0

clipsToBounds를 설정하지 않고 masksToBounds를 true로 설정해야합니다. 이 같은

+0

이 도움이되지 않았다 :

여기에 나는 cornerRadiuswidth을 변경했습니다. 또한 여기에 masksToBounds가 필요하지 않습니다. –

0

사용 :

let infoButton = UIButton(frame: CGRect(x: 0, y: 0, width: 34, height: 24)) 
infoButton.setTitle("₹", for: .normal) 
infoButton.layer.cornerRadius = infoButton.bounds.size.width/2 
infoButton.clipsToBounds = true 
infoButton.layer.borderWidth = 1.5 

enter image description here

+0

아직 완벽한 원형을 얻지 못했습니다. –

+0

'너비'를 늘려보십시오. 나는'iPad'와'iPhone'을 확인해 봤다. –

+0

은 내가 선택한 iOS 11 기기입니까? iOS 10에서 실행되는 모든 기기에서 정상적으로 작동합니다. 문제는 iOS 11 기기에서 발생합니다. –

관련 문제