2014-08-29 3 views
1

내 View Controller 클래스의 viewDidLoad 메서드에서 만든 RubyMotion 앱에 버튼이 있습니다. 그것은 다음과 같습니다내 버튼이 RubyMotion에서 반올림되지 않는 이유는 무엇입니까?

def viewDidLoad 
    @button = UIButton.buttonWithType(UIButtonTypeRoundedRect) 

    @button.setTitle("Tap!", forState: UIControlStateNormal) 
    @button.frame = [ [85, 250], [150, 50] ] 
    @button.backgroundColor = UIColor.darkGrayColor 
    @button.addTarget(self, action: :actionForTheButton, forControlEvents: UIControlEventTouchUpInside) 

    self.view.addSubview(@button) 
end 

는하지만, 내 버튼은 다음과 같습니다 : 나는 문제가 생각하기 때문에,이 버튼으로 일어나고있는 이유를 이해하는 데

enter image description here

을 그 buttonWithType 방법 인수가 UIButtonTypeRoundedRect 인 경우 사각형 모서리가 둥근 모서리가됩니다. 아무도 문제가 무엇인지 명확히 할 수 있습니까?

답변

1

더 이상 사용되지 않으므로 UIButtonTypeRoundedRect에서 멀리 떨어져 있어야합니다. SOURCE : https://developer.apple.com/library/ios/documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html

레이어의 cornerRadius를 설정하여 모든 UIView를 반올림 할 수 있습니다.

내가 지금처럼 UIView의 레이어를 반올림하는 것이 좋습니다 :

def viewDidLoad 
    @button = UIButton.buttonWithType(UIButtonTypeSystem) 

    @button.setTitle("Tap!", forState: UIControlStateNormal) 
    @button.frame = [ [85, 250], [150, 50] ] 
    @button.layer.cornerRadius = 10 # SET THE ROUNDING RADIUS HERE 
    @button.backgroundColor = UIColor.darkGrayColor 
    @button.addTarget(self, action: :actionForTheButton, forControlEvents: UIControlEventTouchUpInside) 

    self.view.addSubview(@button) 
end 
+0

덕분에,이 일했다. – GDP2

관련 문제