Swift开发:Swift 修改UISegmentedControl字体大小,颜色

来源:互联网 发布:零式战斗机知乎 编辑:程序博客网 时间:2024/05/23 01:58

1 Swift code

////  ViewController.swift//  Test////  Created by 开发 on 2017/10/27.//  Copyright © 2017年 com.cuanbo.beaconeu. All rights reserved.//import UIKitclass 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.    }}

2 效果图:

 























原创粉丝点击