iOS: creating an expandable labelHow to create a checkbox with a clickable label?UILabel is not auto-shrinking text to fit label sizeExpanding Multiline UILabelSwift Beta performance: sorting arraysAutoLayout with 2 multiline labels, compression resistance and minimum 1 line labelKeep Anchored Buttons Below Autosized LabelHow to expand - collapse UITextView in Swift?Auto-layout label and image in UITableViewCellRead/see More at the end of the labelProgramatically Created Label Within Container View Won't Expand For Text
What officially disallows US presidents from driving?
Make 2019 with single digits
How do we know that black holes are spinning?
Are there successful ways of getting out of a REVERSE MORTGAGE?
Is there any reason to concentrate on the Thunderous Smite spell after using its effects?
Planar regular languages
Can derivatives be defined as anti-integrals?
Is there a tool to measure the "maturity" of a code in Git?
Is there any way to land a rover on the Moon without using any thrusters?
Cibus sanus — healthy food?
How to count the number of occurences before a particular value in dataframe python?
How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?
How To Make Earth's Oceans as Brackish as Lyr's
Make 1998 using the least possible digits 8
What is this gigantic dish at Ben Gurion airport?
Is a suit against a University Dorm for changing policies on a whim likely to succeed (USA)?
Why the car dealer is insisting on loan instead of cash
Is low emotional intelligence associated with right-wing and prejudiced attitudes?
Are there any “Third Order” acronyms used in space exploration?
Would it be unbalanced to increase Wild Shape uses based on level?
geschafft or geschaffen? which one is past participle of schaffen?
Are space camera sensors usually round, or square?
Permutations in Disguise
Can a character with good/neutral alignment attune to a sentient object with evil alignment?
iOS: creating an expandable label
How to create a checkbox with a clickable label?UILabel is not auto-shrinking text to fit label sizeExpanding Multiline UILabelSwift Beta performance: sorting arraysAutoLayout with 2 multiline labels, compression resistance and minimum 1 line labelKeep Anchored Buttons Below Autosized LabelHow to expand - collapse UITextView in Swift?Auto-layout label and image in UITableViewCellRead/see More at the end of the labelProgramatically Created Label Within Container View Won't Expand For Text
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to create an expandable label that looks like the one in the picture:
I have two problems:
- How do I make the label truncate the tail such that it leaves enough place for the More button/clickable text?
- How do I place the More text?
Maybe, I am going about it the wrong way? Instead of playing with the number of lines, should I maybe try to calculate how much text goes into one and a half line and present it only, and then when clicking More I present the whole text?
Would appreciate any advice, thanks!
ios swift text label expandable
add a comment
|
I'm trying to create an expandable label that looks like the one in the picture:
I have two problems:
- How do I make the label truncate the tail such that it leaves enough place for the More button/clickable text?
- How do I place the More text?
Maybe, I am going about it the wrong way? Instead of playing with the number of lines, should I maybe try to calculate how much text goes into one and a half line and present it only, and then when clicking More I present the whole text?
Would appreciate any advice, thanks!
ios swift text label expandable
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22
add a comment
|
I'm trying to create an expandable label that looks like the one in the picture:
I have two problems:
- How do I make the label truncate the tail such that it leaves enough place for the More button/clickable text?
- How do I place the More text?
Maybe, I am going about it the wrong way? Instead of playing with the number of lines, should I maybe try to calculate how much text goes into one and a half line and present it only, and then when clicking More I present the whole text?
Would appreciate any advice, thanks!
ios swift text label expandable
I'm trying to create an expandable label that looks like the one in the picture:
I have two problems:
- How do I make the label truncate the tail such that it leaves enough place for the More button/clickable text?
- How do I place the More text?
Maybe, I am going about it the wrong way? Instead of playing with the number of lines, should I maybe try to calculate how much text goes into one and a half line and present it only, and then when clicking More I present the whole text?
Would appreciate any advice, thanks!
ios swift text label expandable
ios swift text label expandable
asked Mar 28 at 11:08
YotamYotam
2,9169 gold badges37 silver badges55 bronze badges
2,9169 gold badges37 silver badges55 bronze badges
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22
add a comment
|
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22
add a comment
|
1 Answer
1
active
oldest
votes
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396079%2fios-creating-an-expandable-label%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
add a comment
|
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
add a comment
|
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
answered Mar 28 at 11:53
AtulParmarAtulParmar
2,2169 silver badges26 bronze badges
2,2169 silver badges26 bronze badges
add a comment
|
add a comment
|
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55396079%2fios-creating-an-expandable-label%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How are you going to put it back once the text label is expanded?
– El Tomato
Mar 28 at 12:22