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

前端之家收集整理的这篇文章主要介绍了Swift开发:Swift 修改UISegmentedControl字体大小,颜色前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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.
    }


}

2 效果图:

原文链接:https://www.f2er.com/swift/320990.html

猜你在找的Swift相关文章