Skip to content

Commit

Permalink
Merge pull request #11 from msaravitz/fix-uifontmetrics
Browse files Browse the repository at this point in the history
fix(ios) fix cant find variable UIFontMetrices pre iOS 11
  • Loading branch information
darkmantle authored Mar 18, 2020
2 parents e216964 + d71d413 commit c321009
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/font-scale.ios.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Font, FontWeight } from "tns-core-modules/ui/styling/font";

import { device } from "tns-core-modules/platform";
import { ButtonCommon, LabelCommon, TabStripItemCommon, labelScaleProperty, buttonScaleProperty, tabStripScaleProperty } from "./font-scale.common";

labelScaleProperty.register(LabelCommon);
Expand All @@ -14,6 +14,7 @@ export class Label extends LabelCommon {
const ios: UILabel = this.ios;

if (!this.scale) return;
if (parseInt(device.osVersion) < 11) return;

const newFont = new Font(this.style.fontFamily, this.style.fontSize || 17, null, this.style.fontWeight);
ios.font = UIFontMetrics.defaultMetrics.scaledFontForFont(newFont.getUIFont(null));
Expand All @@ -36,6 +37,7 @@ export class Button extends ButtonCommon {
const ios: UILabel = btn.titleLabel;

if (!this.scale) return;
if (parseInt(device.osVersion) < 11) return;

console.log(this.style.fontSize);

Expand All @@ -60,6 +62,7 @@ export class TabStripItem extends TabStripItemCommon {
const item: UITabBarItem = this.nativeView;

if (!this.scale) return;
if (parseInt(device.osVersion) < 11) return;

const test: NSDictionary<String, any> = item.titleTextAttributesForState(UIControlState.Normal);
const font: UIFont = test.valueForKey("NSFont");
Expand Down

0 comments on commit c321009

Please sign in to comment.