nsattributedstring

Draw a border around a part of NSAttributedString

回眸只為那壹抹淺笑 提交于 2019-12-23 01:52:28
问题 I'm developing a MacOs application and have to implement my own search functional due to custom interface. So the question is - how can a draw a border around a part of NSAttributedString in NSTextView to display search result (just how it's done in TextEdit app). Please check the desired look on the attached image: http://d.pr/i/w8wP [UPDATE] Due to custom interface requirements I can't use NSTextViews's setUsesFindBar: and setUsesFindPanel: . The interface has a custom NSSearchField, which

NSTextField clicked link colour

不想你离开。 提交于 2019-12-22 17:04:11
问题 I have an NSTextField that contains an NSAttributedString which itself contains a clickable link. I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this? 回答1: Seems that I'm not the only one with this problem, and there's a handy class to solve it: https://github.com/laevandus/NSTextFieldHyperlinks 回答2: This ( http://developer.apple.com/library/mac/#qa/qa1487/_index.html ) may help you. It will show you how to set

Hashtags in Arabic language crashes the app

别等时光非礼了梦想. 提交于 2019-12-22 16:34:06
问题 I have a hashtags resolver UITextView extension that turns any word with "#" before it to a tappable blue link. It is working fine except when tapping on Arabic hashtags. extension UITextView { func resolveHashAndMentionTags(){ // turn string in to NSString let nsText:NSString = self.text as NSString // this needs to be an array of NSString. String does not work. let words:[NSString] = nsText.components(separatedBy: " ") as [NSString] // you can't set the font size in the storyboard anymore,

Hashtags in Arabic language crashes the app

孤街醉人 提交于 2019-12-22 16:32:56
问题 I have a hashtags resolver UITextView extension that turns any word with "#" before it to a tappable blue link. It is working fine except when tapping on Arabic hashtags. extension UITextView { func resolveHashAndMentionTags(){ // turn string in to NSString let nsText:NSString = self.text as NSString // this needs to be an array of NSString. String does not work. let words:[NSString] = nsText.components(separatedBy: " ") as [NSString] // you can't set the font size in the storyboard anymore,

Detect Tap On Image's Attached In NSAttributedString While UITextVIew Editing Is True

你。 提交于 2019-12-22 10:59:37
问题 I'm using Below method for detecting taps on image in UITextView . `func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool` This method only call when textView.isEditable = false . So then i add UITapGestureRecognizer on UITextView and it calls when user tap on image inside UITextView . But that point i don't know how i can detect on which image user tap if there is more than one inside

CoreText and strikethrough on iPhone

丶灬走出姿态 提交于 2019-12-22 10:07:26
问题 I'm currently struggling with the need to display strikethrough text in many UITableViewCell s. Something that written in HTML would looke like <strike>€99</strike> save 50% => now €49 I don't want to use a UIWebView just for a single line of text, especially that it's used in small UITableViewCell s. I know there are reusable cells and all, but I'd like to keep things the more memory-efficient way possible. So... I'm using NSAttributedString s, with the help of AliSoftware's UILabel

NSAttributedString '\n' ignored

白昼怎懂夜的黑 提交于 2019-12-22 03:21:54
问题 I have a single view whose only UI element is a UITextView . In viewDidLoad: I create an attributed string with "Text\n" and set the text view's attributed text as such: NSAttributedString *string = [[NSAttributedString alloc] initWithString:@"Text\n"]; [self.textView setAttributedText:string]; My problem is that the line break is ignored when I run the app. If I use an NSString and setText: that doesn't happen. NSString *string = [[NSString alloc] initWithString:@"Text\n"]; [self.textView

NSAttribute string to HTML

笑着哭i 提交于 2019-12-21 20:45:48
问题 I am devloping an application in iOS, and my requirement is to covert HTML string to NSAttributed string and NSAttributed string back to HTML. First part I was able to achieve. But NSAttributed String to HTML is not happening. It returns the string in HTML but not as desired. Please see code and output below: HTML to NSAttributed String NSString *htmlString = @"<div>Test, </div><div> </div><div>Test Test Test</div><div>Test Test Test </div><div> </div><div>Format text:</div><ul style="margin

Programmatically change title color of UIButton whose title set as attributed in iOS 7

笑着哭i 提交于 2019-12-21 20:44:57
问题 I have added one UIButton in my UITableView programmatically. My problem is i need to give the Letter Spacing as well as need to change the button title color. I have given the Letter Spacing in button title text using below code, but title text color is not changing. here is my code : btnLogin = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btnLogin.frame = CGRectMake(0, 0, 320, 42); btnLogin.titleLabel.font = customFont; NSMutableAttributedString *attributedString = [

Objective C - Change all attributes in NSAttributedString?

依然范特西╮ 提交于 2019-12-21 09:55:51
问题 [attributedString enumerateAttributesInRange:range options:NSAttributedStringEnumerationReverse usingBlock: ^(NSDictionary *attributes, NSRange range, BOOL *stop) { NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes]; [mutableAttributes setObject:[NSNumber numberWithInt:1] forKey:@"NSUnderline"]; attributes = mutableAttributes; }]; I am trying to loop through all attributed and add NSUnderline to them. when debugging it seems like NSUnderline is