Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
appinventor-sources
Commits
adae879d
Commit
adae879d
authored
Nov 10, 2023
by
Evan W. Patton
Committed by
Evan W. Patton
Nov 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix font size and encoding issues with iOS Label
Change-Id: I65f4d034903e93dd19f09e051a4192b7ae628da8
parent
35f6a800
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
appinventor/components-ios/src/Label.swift
appinventor/components-ios/src/Label.swift
+11
-10
No files found.
appinventor/components-ios/src/Label.swift
View file @
adae879d
...
...
@@ -14,10 +14,9 @@ public final class Label: ViewComponent, AbstractMethodsForViewComponent, Access
fileprivate
var
_hasMargins
=
false
fileprivate
var
_htmlContent
:
String
=
""
fileprivate
var
_htmlFormat
=
false
fileprivate
var
_fontSize
:
Float64
=
0
fileprivate
var
_fontSize
=
kFontSizeDefault
fileprivate
var
_isBigText
=
false
fileprivate
var
_textColor
=
Int32
(
bitPattern
:
Color
.
default
.
rawValue
)
fileprivate
var
_userFontSize
=
kFontSizeDefault
public
var
HighContrast
:
Bool
=
false
public
override
init
(
_
parent
:
ComponentContainer
)
{
...
...
@@ -33,7 +32,7 @@ public final class Label: ViewComponent, AbstractMethodsForViewComponent, Access
parent
.
add
(
self
)
Height
=
kLengthPreferred
Width
=
kLengthPreferred
FontSize
=
Float64
(
kFontSizeDefault
)
FontSize
=
kFontSizeDefault
}
func
updateFontSize
()
{
...
...
@@ -41,13 +40,13 @@ public final class Label: ViewComponent, AbstractMethodsForViewComponent, Access
updateFormattedContent
()
}
else
{
if
form
?
.
BigDefaultText
==
true
{
if
_
userF
ontSize
==
kFontSizeDefault
{
if
_
f
ontSize
==
kFontSizeDefault
{
_view
.
font
=
_view
.
font
.
withSize
(
CGFloat
(
kFontSizeLargeDefault
))
}
else
{
_view
.
font
=
_view
.
font
.
withSize
(
CGFloat
(
_
userF
ontSize
))
_view
.
font
=
_view
.
font
.
withSize
(
CGFloat
(
_
f
ontSize
))
}
}
else
{
_view
.
font
=
_view
.
font
.
withSize
(
CGFloat
(
_
userF
ontSize
))
_view
.
font
=
_view
.
font
.
withSize
(
CGFloat
(
_
f
ontSize
))
}
}
_view
.
sizeToFit
()
...
...
@@ -139,12 +138,12 @@ public final class Label: ViewComponent, AbstractMethodsForViewComponent, Access
}
}
@objc
public
var
FontSize
:
Float
64
{
@objc
public
var
FontSize
:
Float
{
get
{
return
_fontSize
return
Float
(
_view
.
font
.
pointSize
)
}
set
(
size
)
{
_
userFontSize
=
Float
(
size
)
_
fontSize
=
size
updateFontSize
()
}
}
...
...
@@ -236,7 +235,9 @@ public final class Label: ViewComponent, AbstractMethodsForViewComponent, Access
let
data
=
(
"<div style=
\"\(
style
)\"
>"
+
_htmlContent
+
"</div>"
)
.
data
(
using
:
.
utf8
)
??
Data
()
var
options
=
[
NSAttributedString
.
DocumentReadingOptionKey
:
Any
]()
options
[
NSAttributedString
.
DocumentReadingOptionKey
.
documentType
]
=
NSAttributedString
.
DocumentType
.
html
NSAttributedString
.
DocumentType
.
html
options
[
NSAttributedString
.
DocumentReadingOptionKey
.
characterEncoding
]
=
NSUTF8StringEncoding
_view
.
attributedText
=
try
?
NSAttributedString
(
data
:
data
,
options
:
options
,
documentAttributes
:
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment