1 Swift code
// // ViewController.swift // Test // // Created by 开发 on 2017/10/27. // Copyright © 2017年 com.cuanbo.beaconeu. All rights reserved. // import UIKit class ViewController: UIViewController { @IBOutlet weak var seg1: UISegmentedControl! override func viewDidLoad() { super.viewDidLoad() //dic 属性值 //UITextAttributeTextColor //UITextAttributeTextShadowColor //UITextAttributeTextShadowOffset //UITextAttributeFont //UIFontfontWithName let dic:NSDictionary = [NSForegroundColorAttributeName:UIColor.red,NSFontAttributeName:UIFont.boldSystemFont(ofSize: 25)]; seg1.setTitleTextAttributes(dic as! [AnyHashable : Any],for: UIControlState.normal); } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } @H_403_9@
2 效果图:
原文链接:https://www.f2er.com/swift/320990.html