我正在改变像这样的UIButton标题的字体:
self.titleLabel?.font = UIFont(name: "SF UI Display", size: 30)
我如何改变重量(我认为XCode称之为“风格”)?它目前默认为中等,我需要它是常规的。
答案 0 :(得分:2)
您可以下载The Regular Font
尝试打印字体名称:
self.titleLabel?.font = UIFont(name: "pass the name of downloaded file", size: 30) //Pass the name of downloaded file here
然后将其设置如下:
Target Membership
注意: - 下载并拖放到您的项目后,不要忘记检查self.titleLabel?.font = UIFont(name: "SFUIDisplayRegular", size: 20)
是否勾选,如果没有,则勾选它或它不起作用你
通过移入垃圾箱然后
删除现有的字体文件下载后更改文件名 SFUIDisplayRegular.otf
勾选目标会员
public class AppiumController{
public static void main(String[] args) throws MalformedURLException{
AppiumDriver<?> driver;
final String URL_STRING = "http://127.0.0.1:4723/wd/hub";
URL url = new URL(URL_STRING);
File appDirAndroid = new File("src/main/resources/app/");
File appAndroid = new File(appDirAndroid, "in.amazon.mShop.android.shopping_2018-02-22.apk");
DesiredCapabilities androidCapabilities = new DesiredCapabilities();
androidCapabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
androidCapabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
androidCapabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator-5554");
androidCapabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
androidCapabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
androidCapabilities.setCapability(MobileCapabilityType.APP, appAndroid.getAbsolutePath());
driver = new AndroidDriver<MobileElement>(url, androidCapabilities);
driver.closeApp();
}
}
它会对你有用,
干杯!
请参阅输出:
答案 1 :(得分:1)
试试这个代码。它为你工作
self.titleLabel?.font = UIFont(name: "SFUIDisplay-Regular", size: 30)
答案 2 :(得分:1)
在使用字体名称后 - 并键入您需要的样式名称,确保在xcode项目中存在或支持具有该样式名称的字体文件。
struct Fonts {
static let regular12 = UIFont.init(name: "OpenSans", size: 12) ?? UIFont.systemFont(ofSize: 12)
static let regular14 = UIFont.init(name: "OpenSans", size: 14) ?? UIFont.systemFont(ofSize: 14)
static let regular16 = UIFont.init(name: "OpenSans", size: 16) ?? UIFont.systemFont(ofSize: 16)
static let regular18 = UIFont.init(name: "OpenSans", size: 18) ?? UIFont.systemFont(ofSize: 18)
static let semiBold12 = UIFont.init(name: "OpenSans-Semibold", size: 12) ?? UIFont.systemFont(ofSize: 12)
static let semiBold14 = UIFont.init(name: "OpenSans-Semibold", size: 14) ?? UIFont.systemFont(ofSize: 14)
static let semiBold16 = UIFont.init(name: "OpenSans-Semibold", size: 16) ?? UIFont.systemFont(ofSize: 16)
static let bold12 = UIFont.init(name: "OpenSans-Bold", size: 12) ?? UIFont.systemFont(ofSize: 12)
static let bold14 = UIFont.init(name: "OpenSans-Bold", size: 14) ?? UIFont.systemFont(ofSize: 14)
static let bold16 = UIFont.init(name: "OpenSans-Bold", size: 16) ?? UIFont.systemFont(ofSize: 16)
static let regular20 = UIFont.init(name: "OpenSans", size: 20) ?? UIFont.systemFont(ofSize: 20)
}
我在项目中用于字体的文件名如下: - Google字体 - Open Sans Bold Italic.ttf,Google字体 - Open Sans Bold.ttf,Google字体 - Open Sans Semibold.ttf等。