nsmutableattributedstring

Crash in iOS 7.0.3 for NSMutableAttributedString [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 05:56:16
问题 This question already has answers here : What happened to “HelveticaNeue-Italic” on iOS 7.0.3 (10 answers) Closed 6 years ago . Since a few days, I have a crash that only happens in iOS with the following line of code [myAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Italic" size:myLabel.font.pointSize] range:rangeOfSubString]; The reason given by debugger is "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:

NSMutableAttributedString's attribute NSStrikethroughStyleAttributeName doesn't work correctly in iOS8

青春壹個敷衍的年華 提交于 2019-12-18 13:27:53
问题 I have a mutable attributed string without NSStrikethroughStyleAttributeName attribute like this: NSMutableAttributedString *str1 = [[NSMutableAttributedString alloc] initWithString:@"aaaa" attributes:@{NSStrikethroughStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle]}]; and another mutable attributed string with NSStrikethroughStyleAttributeName attribute like this: NSMutableAttributedString *str2 = [[NSMutableAttributedString alloc] initWithString:@"bbbb"]; and a whole

Underline part of a string using NSMutableAttributedString in iOS 8 is not working

一世执手 提交于 2019-12-17 22:19:29
问题 I try to underline part of a string, for example, a ' string ' part in ' test string ' string. I'm using NSMutableAttributedString and my solution was working well on iOS7 . NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"test string"]; [attributedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(5, 6)]; myLabel.attributedText = attributedString; The problem is that my solution is not working

Displaying text in a NSScrollView (Swift)

拈花ヽ惹草 提交于 2019-12-17 19:44:17
问题 Just started to learn Swift and created a little macOS app in which I want to use a NSScrollView to display an attributed String. I’ve tried: @IBOutlet var ScrollViewOutlet : NSScrollView var attributedString = NSMutableAttributedString(string: myText) ScrollViewOutlet.insertText(attributedString) But that doesn’t seem to work. Feels confusing since doing the exact same with a NSTextView instead works like a charm. What am I missing here? 回答1: In the following example, I added the scrollView

NSTextAttachment image not displayed on iOS 8 devices (with iOS7.1 sdk)

北慕城南 提交于 2019-12-13 00:44:58
问题 I have just built my project on several iOS 8 devices with baseSDK set to iOS 7.1. Unfortunately, all NSTextAttachment images added as attributes to relevant instances of NSMutableAttributedString are hidden on iOS 8 devices and the iOS 8 simulator (they are still visible on devices with 7.1 and the iOS 7.1 simulator). The frame for these strings within their superviews is set as if the image was there, but the image itself is just not visible or rendered. Has anybody else ran into the issue

NSMutableAttributedString as UIAlertAction's title - Swift

ε祈祈猫儿з 提交于 2019-12-11 18:27:41
问题 Is it possible to set a NSMutableAttributedString as AlertAction's title? My aim is to visualize a math expression with a good design in my UIAlertAction's title. let action = UIAlertAction(title: myNSMutableAttributedString, style: UIAlertActionStyle.default) {(result : UIAlertAction) -> Void in } Thanks in advance for the help. 回答1: It's not possible to use an NSAttributedString for a UIAlertAction 's title without accessing private APIs, as the method for setting the attributedTitle to an

NSTextView making bold text using an array

心已入冬 提交于 2019-12-11 09:42:45
问题 I have an array which has the following structure: ( [0] = ( [0] = @"Title string" [1] = @"Some content string" ) [1] = ( [0] = @"Title string" [1] = @"Some content string" ) [2] = ( [0] = @"Title string" [1] = @"Some content string" ) ... ) and so on and so fourth to a variating amount of reoccurrence. My goal is to try and merge it all into one single string to display in an NSTextField, and make every title string bold. So the code above would look something like this if it were outputted.

Which replacement method is called when editing an attributed string?

核能气质少年 提交于 2019-12-11 05:29:22
问题 NSMutableAttributedString defines two string replacement methods: func replaceCharacters(in range: NSRange, with str: String) and func replaceCharacters(in range: NSRange, with attrString: NSAttributedString) I have created a subclass of NSTextStorage which in its turn is a subclass of NSMutableAttributedString . In that subclass I overrode both of the above methods. To my surprise, the latter method (which passes an attributed replacement string) is never called when I type or paste

Replace character in NSMutableAttributedString

北慕城南 提交于 2019-12-10 21:48:14
问题 This works for a regular NSString : NSString *newString = [myString stringByReplacingOccurrencesOfString:@"," withString:@""]; But there is no such method for NSMutableAttributedString . How could I remove all instances of a comma in an NSMutableAttributedString ? 回答1: let attrString = NSMutableAttributedString(string: "Hello <b>friend<b>") attrString.mutableString.replaceOccurrencesOfString("<b>", withString: "", options: NSStringCompareOptions.CaseInsensitiveSearch, range: NSRange(location:

Add NSAttributedString to UIBarButtonItem

南楼画角 提交于 2019-12-10 17:33:22
问题 I'm attempting to set an attributed string on my back bar button item. This is my first attempt at attributed strings. Here is the code: self.navigationItem.hidesBackButton = true let barButtonBackStr = "< Back" var attributedBarButtonBackStr = NSMutableAttributedString(string: barButtonBackStr as String) attributedBarButtonBackStr.addAttribute(NSFontAttributeName, value: UIFont( name: "AmericanTypewriter-Bold", size: 18.0)!, range: NSRange( location:0, length:1)) let newBackButton =