修改UISegmentedControl的字體大小

Henry Huang
2 min readFeb 8, 2018

--

因為UISegmentedControl內容的字體無法直接在storyboard直接調整,所以如果把SegmentedControl的高度調高,可能會覺得字有點小,所以就找了一下解決辦法,感謝估狗大神:

class ViewController: UIViewController {

@IBOutlet weak var mySegmented: UISegmentedControl!

override func viewDidLoad() {
super.viewDidLoad()

let customFont:NSDictionary = [NSForegroundColorAttributeName:UIColor.red,NSFontAttributeName:UIFont.boldSystemFont(ofSize: 20)];

mySegmented.setTitleTextAttributes(customFont as? [AnyHashable : Any], for: .normal);

}
}
//属性
//UITextAttributeTextColor
//UITextAttributeTextShadowColor
//UITextAttributeTextShadowOffset
//UITextAttributeFont
//UIFontfontWithName

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Henry Huang
Henry Huang

Written by Henry Huang

大學讀企管/退伍後在業務圈打滾6年後突然有一天決定投入完全沒接觸過的程式設計/目前為一位iOS Developer/熱愛NBA/dafu1231@gmail.com

No responses yet

Write a response