This image shows what I am trying to achieve:
I am specifying the width of 2 buttons, to be the same as 0.4*redViewWidth and height 0.8*redViewheight. Than I want the text size to be in 2 lines and as big as possible to still fit into the buttons frames. I am using custom font and no auto-layout. To my surprise, this doesn't happen. The text is in 2 lines, but the text font size is too large and definitively not fitting button size. Where did I go wrong?
edit: redView uses autolayout. Populating redView with buttons uses none.
let font = UIFont(name: "customfont", size: 19)
button1 = UIButton()
button2 = UIButton()
button1.frame = CGRectMake(navigationBarView.frame.width*0.6, navigationBarView.frame.height*0.1, navigationBarView.frame.width*0.4, navigationBarView.frame.height*0.8)
button2.frame = CGRectMake(navigationBarView.frame.width*0.2, navigationBarView.frame.height*0.1, navigationBarView.frame.width*0.4, navigationBarView.frame.height*0.8)
button1.setTitle("button2\ntext text text text", forState: UIControlState.Normal)
button1.titleLabel?.textAlignment = NSTextAlignment.Center
button1.titleLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
button1.titleLabel?.font=font
button1.titleLabel?.adjustsFontSizeToFitWidth=true
button1.titleLabel?.minimumScaleFactor = 0.1
button2.setTitle("button1\ntext text text text", forState: UIControlState.Normal)
button2.titleLabel?.textAlignment = NSTextAlignment.Center
button2.titleLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping
button2.titleLabel?.font=font
button2.titleLabel?.adjustsFontSizeToFitWidth=true
button2.titleLabel?.minimumScaleFactor = 0.1