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;








0















I want to draw a strike through line in swift 4 as shown in below image.



enter image description here



I have drawn strike through line as shown in below image using followed code.



enter image description here



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.










share|improve this question






















  • 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

















0















I want to draw a strike through line in swift 4 as shown in below image.



enter image description here



I have drawn strike through line as shown in below image using followed code.



enter image description here



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.










share|improve this question






















  • 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













0












0








0








I want to draw a strike through line in swift 4 as shown in below image.



enter image description here



I have drawn strike through line as shown in below image using followed code.



enter image description here



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.










share|improve this question














I want to draw a strike through line in swift 4 as shown in below image.



enter image description here



I have drawn strike through line as shown in below image using followed code.



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















2














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)






share|improve this answer

























  • 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











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
);



);













draft saved

draft discarded


















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









2














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)






share|improve this answer

























  • 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
















2














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)






share|improve this answer

























  • 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














2












2








2







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)






share|improve this answer















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)







share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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









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.




















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현