iOS开发之字体样式设置大全:常用的字体样式设置方法
2023.05.05 15:24浏览量:1379简介:ios开发之字体样式设置大全
ios开发之字体样式设置大全
在ios开发中,字体样式设置是一个非常重要的环节,因为它直接关系到应用的美观度和易用性。本文将介绍ios开发中常用的字体样式设置方法,包括字体、字号、字体颜色、粗细、行高、字体大小、斜体、下划线、连字符、换行符等。
一、字体
- 设置字体:在Xcode中,可以通过点击ViewController.h/.m文件中的NSString来设置字体。
NSString *fontName = @"Helvetica";
- 设置字体大小:在ViewController.h/.m文件中,可以通过设置fontSize属性来改变字体大小。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.fontSize = 20.0;
- 设置字体类型:在ViewController.h/.m文件中,可以通过设置type属性来改变字体类型。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeCustom;
- 设置字体风格:在ViewController.h/.m文件中,可以通过设置style属性来改变字体风格。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeRegular;
self.style = UIFontStyleRegular;
二、字号
- 设置字号:在ViewController.h/.m文件中,可以通过设置fontSize属性来改变字号。
self.fontSize = 20.0;
- 设置等比例缩放字号:在ViewController.h/.m文件中,可以通过设置type属性来改变等比例缩放字号。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeCustom;
self.style = UIFontStyleItalic;
self.fontSize = 20.0;
- 设置非等比例缩放字号:在ViewController.h/.m文件中,可以通过设置fontSize和type属性来改变非等比例缩放字号。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeRegular;
self.fontSize = 20.0;
三、字体颜色
- 设置字体颜色:在ViewController.h/.m文件中,可以通过设置textColor属性来改变字体颜色。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeCustom;
self.textColor = [UIColor whiteColor];
- 设置非等比例缩放字体颜色:在ViewController.h/.m文件中,可以通过设置textColor和type属性来改变非等比例缩放字体颜色。
self.fontName = [NSString stringWithFormat:@"%@", fontName];
self.type = UIFontTypeRegular;
self.textColor = [UIColor whiteColor];
四、粗细
- 设置粗细:在ViewController.h/.m文件中,可以通过设置lineHeight属性来改变粗细。
```objective
self.fontName = [NSString stringWithFormat:@”%@”, fontName];
发表评论
登录后可评论,请前往 登录 或 注册