【发布时间】:2023-04-01 18:17:01
【问题描述】:
我尝试在按钮上换行如下:
nextButton=UIButton(frame: CGRectMake(buttonHWidth, textHeigth, buttonHWidth, buttonHeigth));
nextButton.backgroundColor = UIColor.lightGrayColor()
nextButton.setTitle("", forState: UIControlState.Normal)
nextButton.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
nextButton.tag = 22;
label_nextButton = UILabel(frame: CGRectMake(buttonHWidth, textHeigth, buttonHWidth, buttonHeigth));
label_nextButton.textAlignment = NSTextAlignment.Center;
label_nextButton.numberOfLines = 2;
label_nextButton.font = UIFont.systemFontOfSize(16.0);
label_nextButton.text = "Prss next Press next";
label_nextButton.textColor=UIColor.blackColor();
nextButton.addSubview(label_nextButton);
self.view.addSubview(nextButton);
我可以看到设备上的按钮,但看不到任何文字。
我做错了什么?或者这可以在不向按钮添加标签的情况下完成吗? 感谢您的帮助。
插图。它看起来像:
刚做的时候:
nextButton.setTitle("this is a very very long text", forState: UIControlState.Normal)
【问题讨论】:
标签: ios swift uibutton uilabel