NSAttributed Text with a line along with some angle in iOSGetting the range of links in attributed stringMultiple lines of text in UILabelVertically align text to top within a UILabelUITextField text change eventHow to change Status Bar text color in iOSDraw Angled/Rotated MultiLine Text - Core Text + Core GraphicsImage becomes blurry when painting a Image from GraphicContext?How to give multiple colours for a plot with CoreplotiOS Swift Draw line with a brush effectDrawing a 3D cone shape in Swift using a UIBezierPath() and CAShapeLayer()draw a straight line in swift 3 and core graphics
Why do I need two parameters in an HTTP parameter pollution attack?
Skipping over failed imports until they are needed (if ever)
What's the easiest way for a whole party to be able to communicate with a creature that doesn't know Common?
Does the Pi 4 resolve the Ethernet+USB bottleneck issue of past versions?
Why was Mal so quick to drop Bester in favour of Kaylee?
Can the passive "être + verbe" sometimes mean the past?
How exactly is a normal force exerted, at the molecular level?
What's the safest way to inform a new user of their password on my web site?
Can I create a CAA record for all sub-domains
Can I ask to speak to my future colleagues before accepting an offer?
What is the highest number of sneak attacks that a Pure/High Level Rogue (Level 17+) can make in one round?
One folder two different locations on ubuntu 18.04
Should I share with a new service provider a bill from its competitor?
How can my story take place on Earth without referring to our existing cities and countries?
Is it bad to describe a character long after their introduction?
How to fix a dry solder pin in BGA package?
Can Access Fault Exceptions of the MC68040 caused by internal access faults occur in normal situations?
Spicket or spigot?
Why does a brace command group need spaces after the opening brace in POSIX Shell Grammar?
Can two or more lightbeams (from a laser for example) have visible interference when they cross in mid-air?
Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?
Are these intended activities legal to do in the USA under the VWP?
Should I report a leak of confidential HR information?
What could a reptilian race tell by candling their eggs?
NSAttributed Text with a line along with some angle in iOS
Getting the range of links in attributed stringMultiple lines of text in UILabelVertically align text to top within a UILabelUITextField text change eventHow to change Status Bar text color in iOSDraw Angled/Rotated MultiLine Text - Core Text + Core GraphicsImage becomes blurry when painting a Image from GraphicContext?How to give multiple colours for a plot with CoreplotiOS Swift Draw line with a brush effectDrawing a 3D cone shape in Swift using a UIBezierPath() and CAShapeLayer()draw a straight line in swift 3 and core graphics
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I want to draw a strike through line in swift 4 as shown in below image.
I have drawn strike through line as shown in below image using followed code.
func strikeThrough(_ color: UIColor) -> NSAttributedString
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: self)
let textRange = NSRange(location: 0, length: attributeString.length)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 1, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.baselineOffset, value: 0, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.lightGray, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.strikethroughColor, value: color, range: textRange)
return attributeString
Any suggestions how do I draw the inclined line over text.
If possible give me a solution using Core Graphics.
ios swift swift4 line nsattributedstring
add a comment |
I want to draw a strike through line in swift 4 as shown in below image.
I have drawn strike through line as shown in below image using followed code.
func strikeThrough(_ color: UIColor) -> NSAttributedString
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: self)
let textRange = NSRange(location: 0, length: attributeString.length)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 1, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.baselineOffset, value: 0, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.lightGray, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.strikethroughColor, value: color, range: textRange)
return attributeString
Any suggestions how do I draw the inclined line over text.
If possible give me a solution using Core Graphics.
ios swift swift4 line nsattributedstring
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17
add a comment |
I want to draw a strike through line in swift 4 as shown in below image.
I have drawn strike through line as shown in below image using followed code.
func strikeThrough(_ color: UIColor) -> NSAttributedString
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: self)
let textRange = NSRange(location: 0, length: attributeString.length)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 1, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.baselineOffset, value: 0, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.lightGray, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.strikethroughColor, value: color, range: textRange)
return attributeString
Any suggestions how do I draw the inclined line over text.
If possible give me a solution using Core Graphics.
ios swift swift4 line nsattributedstring
I want to draw a strike through line in swift 4 as shown in below image.
I have drawn strike through line as shown in below image using followed code.
func strikeThrough(_ color: UIColor) -> NSAttributedString
let attributeString: NSMutableAttributedString = NSMutableAttributedString(string: self)
let textRange = NSRange(location: 0, length: attributeString.length)
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 1, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.baselineOffset, value: 0, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.lightGray, range: textRange)
attributeString.addAttribute(NSAttributedString.Key.strikethroughColor, value: color, range: textRange)
return attributeString
Any suggestions how do I draw the inclined line over text.
If possible give me a solution using Core Graphics.
ios swift swift4 line nsattributedstring
ios swift swift4 line nsattributedstring
asked Mar 25 at 12:40
Krishnarjun BanothKrishnarjun Banoth
6228 silver badges23 bronze badges
6228 silver badges23 bronze badges
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17
add a comment |
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17
add a comment |
1 Answer
1
active
oldest
votes
Use UIBezierPath with your UILabel, let's name it label:
var aPath = UIBezierPath()
aPath.moveToPoint(CGPoint(x: label.frame.origin.x , y:label.frame.origin.y - 10)
aPath.addLineToPoint(CGPoint(x: label.frame.origin.x + label.frame.size.width, y: label.frame.origin.y + label.frame.size.height + 10))
aPath.closePath()
UIColor.redColor().set()
aPath.stroke()
Feel free to play with origins of Points in order to get desired result. Also play with label.layer.addSublayer(aPath)
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
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/3.0/"u003ecc by-sa 3.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%2f55338027%2fnsattributed-text-with-a-line-along-with-some-angle-in-ios%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
Use UIBezierPath with your UILabel, let's name it label:
var aPath = UIBezierPath()
aPath.moveToPoint(CGPoint(x: label.frame.origin.x , y:label.frame.origin.y - 10)
aPath.addLineToPoint(CGPoint(x: label.frame.origin.x + label.frame.size.width, y: label.frame.origin.y + label.frame.size.height + 10))
aPath.closePath()
UIColor.redColor().set()
aPath.stroke()
Feel free to play with origins of Points in order to get desired result. Also play with label.layer.addSublayer(aPath)
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
add a comment |
Use UIBezierPath with your UILabel, let's name it label:
var aPath = UIBezierPath()
aPath.moveToPoint(CGPoint(x: label.frame.origin.x , y:label.frame.origin.y - 10)
aPath.addLineToPoint(CGPoint(x: label.frame.origin.x + label.frame.size.width, y: label.frame.origin.y + label.frame.size.height + 10))
aPath.closePath()
UIColor.redColor().set()
aPath.stroke()
Feel free to play with origins of Points in order to get desired result. Also play with label.layer.addSublayer(aPath)
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
add a comment |
Use UIBezierPath with your UILabel, let's name it label:
var aPath = UIBezierPath()
aPath.moveToPoint(CGPoint(x: label.frame.origin.x , y:label.frame.origin.y - 10)
aPath.addLineToPoint(CGPoint(x: label.frame.origin.x + label.frame.size.width, y: label.frame.origin.y + label.frame.size.height + 10))
aPath.closePath()
UIColor.redColor().set()
aPath.stroke()
Feel free to play with origins of Points in order to get desired result. Also play with label.layer.addSublayer(aPath)
Use UIBezierPath with your UILabel, let's name it label:
var aPath = UIBezierPath()
aPath.moveToPoint(CGPoint(x: label.frame.origin.x , y:label.frame.origin.y - 10)
aPath.addLineToPoint(CGPoint(x: label.frame.origin.x + label.frame.size.width, y: label.frame.origin.y + label.frame.size.height + 10))
aPath.closePath()
UIColor.redColor().set()
aPath.stroke()
Feel free to play with origins of Points in order to get desired result. Also play with label.layer.addSublayer(aPath)
edited Mar 25 at 12:50
answered Mar 25 at 12:47
user3344236user3344236
2,9741 gold badge15 silver badges21 bronze badges
2,9741 gold badge15 silver badges21 bronze badges
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
add a comment |
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
When we use frames it misbehaves when we rotate the screen.
– Krishnarjun Banoth
Mar 25 at 12:49
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
The example above gives you an idea. No mention for rotate screen etc :) Anyway adding as sublayer shall fix this issue. See updated response.
– user3344236
Mar 25 at 12:51
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%2f55338027%2fnsattributed-text-with-a-line-along-with-some-angle-in-ios%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
You can use developer.apple.com/documentation/uikit/nslayoutmanager/… and a sample (for underline, but the logic on how to use it is the same: stackoverflow.com/questions/55288142/…), and customize it according to your needs
– Larme
Mar 26 at 11:17