iOS添加自定义自体 [UIFont fontWithName: size:](英文有效)

 [UIFont fontWithName:(NSString *)fontName size:(CGFloat)fontSize];

//便利字体名称

for (NSString *str in [UIFont familyNames]) {

        dlog(@"UIFont_name: %@",str);

}

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Marion

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Copperplate

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Heiti SC

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Iowan Old Style

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Courier New

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Apple SD Gothic Neo

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Heiti TC

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Gill Sans

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Marker Felt

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Thonburi

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Avenir Next Condensed

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Tamil Sangam MN

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Helvetica Neue

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Gurmukhi MN

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Times New Roman

2015-05-25 16:36:46.591 pengsi[10717:2381284] UIFont_name: Georgia

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Apple Color Emoji

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Arial Rounded MT Bold

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Kailasa

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Kohinoor Devanagari

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Sinhala Sangam MN

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Chalkboard SE

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Superclarendon

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Gujarati Sangam MN

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Damascus

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Noteworthy

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Geeza Pro

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Avenir

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Academy Engraved LET

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Mishafi

2015-05-25 16:36:46.596 pengsi[10717:2381284] UIFont_name: Futura

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Farah

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Kannada Sangam MN

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Arial Hebrew

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Arial

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Party LET

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Chalkduster

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Hiragino Kaku Gothic ProN

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Hoefler Text

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Optima

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Palatino

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Malayalam Sangam MN

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Lao Sangam MN

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Al Nile

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Bradley Hand

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Hiragino Mincho ProN

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Trebuchet MS

2015-05-25 16:36:46.597 pengsi[10717:2381284] UIFont_name: Helvetica

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Courier

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Cochin

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Devanagari Sangam MN

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Oriya Sangam MN

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Snell Roundhand

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Zapf Dingbats

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Bodoni 72

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Verdana

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: American Typewriter

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Avenir Next

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Baskerville

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Khmer Sangam MN

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Didot

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Savoye LET

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Bodoni Ornaments

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Symbol

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Menlo

2015-05-25 16:36:46.598 pengsi[10717:2381284] UIFont_name: Bodoni 72 Smallcaps

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: DIN Alternate

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Papyrus

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Euphemia UCAS

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Telugu Sangam MN

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Bangla Sangam MN

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Zapfino

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: Bodoni 72 Oldstyle

2015-05-25 16:36:46.599 pengsi[10717:2381284] UIFont_name: DIN Condensed


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iOS 的自定义 TabBar 主要分为以下几个步骤: 1. 创建自定义 TabBar 创建一个继承于 UITabBar 的类,重写初始化方法和 layoutSubviews 方法,实现自定义 TabBar 的样式和布局。 2. 实现自定义 TabBarItem 创建一个继承于 UIButton 的类,用于实现自定义的 TabBarItem 样式,例如添加图片、文字等。 3. 设置自定义 TabBarItem 在自定义 TabBar 的初始化方法中,添加定义的 TabBarItem,将其添加到 TabBar 上。 4. 替换系统 TabBar 在 AppDelegate 中,找到 TabBarController 的 tabBar 属性,将其替换为自定义的 TabBar。 示例代码: 自定义 TabBar 类: ``` class CustomTabBar: UITabBar { var items: [CustomTabBarItem] = [] override init(frame: CGRect) { super.init(frame: frame) setup() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setup() { // 隐藏默认的 TabBar self.tintColor = .clear self.backgroundImage = UIImage() self.shadowImage = UIImage() self.backgroundColor = .white } override func layoutSubviews() { super.layoutSubviews() // 设置自定义 TabBarItem 的布局 let itemWidth = self.frame.size.width / CGFloat(items.count) var itemIndex: CGFloat = 0 for item in items { item.frame = CGRect(x: itemWidth * itemIndex, y: 0, width: itemWidth, height: self.frame.size.height) itemIndex += 1 } } } ``` 自定义 TabBarItem 类: ``` class CustomTabBarItem: UIButton { var title: String? var normalImage: UIImage? var selectedImage: UIImage? override init(frame: CGRect) { super.init(frame: frame) setup() } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setup() { // 设置 TabBarItem 的样式 self.imageView?.contentMode = .scaleAspectFit self.titleLabel?.font = UIFont.systemFont(ofSize: 12) self.setTitleColor(.gray, for: .normal) self.setTitleColor(.black, for: .selected) } override func layoutSubviews() { super.layoutSubviews() // 设置 TabBarItem 的布局 let imageHeight = self.frame.size.height * 0.6 self.imageView?.frame = CGRect(x: (self.frame.size.width - imageHeight) / 2, y: 5, width: imageHeight, height: imageHeight) self.titleLabel?.frame = CGRect(x: 0, y: self.frame.size.height - 20, width: self.frame.size.width, height: 20) } func set(title: String?, normalImage: UIImage?, selectedImage: UIImage?) { self.title = title self.normalImage = normalImage self.selectedImage = selectedImage // 设置 TabBarItem 的标题和图片 self.setTitle(title, for: .normal) self.setImage(normalImage, for: .normal) self.setImage(selectedImage, for: .selected) } } ``` 在自定义 TabBar 的初始化方法中,添加定义的 TabBarItem: ``` class CustomTabBar: UITabBar { var items: [CustomTabBarItem] = [] override init(frame: CGRect) { super.init(frame: frame) setup() // 添加 TabBarItem let item1 = CustomTabBarItem() item1.set(title: "首页", normalImage: UIImage(named: "home_normal"), selectedImage: UIImage(named: "home_selected")) self.addSubview(item1) items.append(item1) let item2 = CustomTabBarItem() item2.set(title: "消息", normalImage: UIImage(named: "message_normal"), selectedImage: UIImage(named: "message_selected")) self.addSubview(item2) items.append(item2) let item3 = CustomTabBarItem() item3.set(title: "我的", normalImage: UIImage(named: "mine_normal"), selectedImage: UIImage(named: "mine_selected")) self.addSubview(item3) items.append(item3) } // ... } ``` 在 AppDelegate 中,找到 TabBarController 的 tabBar 属性,将其替换为自定义的 TabBar: ``` func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // ... let tabBarController = UITabBarController() tabBarController.viewControllers = [viewController1, viewController2, viewController3] // 替换为自定义 TabBar let customTabBar = CustomTabBar(frame: tabBarController.tabBar.frame) tabBarController.setValue(customTabBar, forKey: "tabBar") // ... return true } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值