nsattributedstring

TTT attributed Label Multi- colored Font help

无人久伴 提交于 2019-12-01 07:31:24
问题 -(UITableViewCell*) makeLikeCell { // Load the top-level objects from the custom cell XIB. NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SpotlightLikesTableViewCell" owner: self options: nil]; // Grab a pointer to the first object (presumably the custom cell, as that's all the XIB should contain). UITableViewCell *cell = [topLevelObjects objectAtIndex:0]; NSString *likeText = [likesAndComments objectAtIndex: kLikeRow]; TTTAttributedLabel *likeLabel = [[[TTTAttributedLabel

Rich-text editor in iOS [closed]

自作多情 提交于 2019-12-01 07:22:31
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am looking for a sample project which should have basic rich text editing features (Bold,Italic,Underline,Alignment,Attaching images). I went through Google search results there are several editors available for iOS but those all are developed by using UIWebView with HTML . I am looking for the one which

Add a regular action to an NSAttributedString?

醉酒当歌 提交于 2019-12-01 06:02:30
问题 I simply want to add an objetive-c action to be called upon a tap on a certain range in my UILabel using NSAttributedString. But I don't know how to do it. I don't want to open a URL, I just wanna to call a method. Thanks 回答1: You can use NSLinkAttributeName itself to achieve this. Use an attributed string as shown below and set it as the text of a UITextView. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:termsString]; [attributedString

How to consistently draw NSAttributedString in UITextView in UITableViewCell

倾然丶 夕夏残阳落幕 提交于 2019-12-01 05:56:26
I am having trouble getting consistent results from UITextViews in a UITableViewCell using NSAttributedStrings. Inside - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; headerText = [[UITextView alloc]initWithFrame:CGRectZero]; [headerText setUserInteractionEnabled:NO]; headerText.tag = HEADER_TEXT; [cell.contentView addSubview

NSAttributedString alignment not working on html content

蹲街弑〆低调 提交于 2019-12-01 05:22:26
Want to change alignment of html label. Nothing works. I don't see any CSS in the HTML. There are no further settings changing the alignment. I also set left alignment directly on the UILabel. What am I missing? The code is in UILabel extension. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; paragraphStyle.alignment = NSTextAlignmentLeft; NSDictionary *attr = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding),

How to create a subscript with NSAttributedString

强颜欢笑 提交于 2019-12-01 05:17:51
I see for NSAttributedString has a specific attribute for superscript, but I can't find one for subscript. What is the general practice for using NSAttributedString to create a subscript character? Example: H2O Try NSSuperscriptAttributeName with a negative value. Failing that, the hard way would be to replace [0123456789] characters with [₀₁₂₃₄₅₆₇₈₉] in the string. I struggled with subscripts/superscripts in NSMutableAttributedString for a while because the most basic solutions require inputting a NSRange for each and every character you want to subscript. Surely there's a more automatic way

How to consistently draw NSAttributedString in UITextView in UITableViewCell

狂风中的少年 提交于 2019-12-01 03:04:17
问题 I am having trouble getting consistent results from UITextViews in a UITableViewCell using NSAttributedStrings. Inside - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; headerText = [[UITextView alloc]initWithFrame:CGRectZero];

Find last visible line index in NSAttributedString's drawWithRect

牧云@^-^@ 提交于 2019-12-01 01:40:24
I am creating a pdf from user provided text, however I have an issue when the text is too big for the page, I have to calculate where the text would be cut off so I can move the next chunk to the next page. I use this code to draw the attributed text: CGRect rect = CGRectFromString(elementInfo[@"rect"]); NSString *text = elementInfo[@"text"]; NSDictionary *attributes = elementInfo[@"attributes"]; NSAttributedString *attString = [[NSAttributedString alloc] initWithString:text attributes:attributes]; [attString drawWithRect:rect options:NSStringDrawingUsesLineFragmentOrigin |

Parsing text from plist to NSAttributedString

点点圈 提交于 2019-11-30 22:33:48
I'm loading in text from a plist and displaying it within my app. Ideally I want to be able to specify more complex formatting such as italics, bold and superscript text, and display it in a custom label such as TTTAttributedLabel . Are there any available libraries to parse a string in a given format (preferably a simple text format such as Markdown or Textile) into an NSAttributedString? I am aware that solutions are available for parsing RTF and HTML, but this is overkill for my needs - plus I'd like the text to be easily written by hand. Edit: this is for iOS/UIKit I've just added an

Find CGPoint Location of substring in TextView

人盡茶涼 提交于 2019-11-30 21:13:26
I'm looking to create a SpriteKit Node positioned at the location of a substring inside a UITextView. How would I retrieve the CGPoint location so I can position the SKNode there? let textFont = [NSFontAttributeName: UIFont(name: "GillSansMT", size: 30.0) ?? UIFont.systemFontOfSize(18.0)] attrString1 = NSMutableAttributedString(string: "My name is Dug.", attributes: textFont) textShown1 = CustomTextView(frame: CGRectMake(CGRectGetMidX(self.frame), 175 + (90 * paragraphNumber), CGRectGetWidth(self.frame) - 80, CGRectGetHeight(self.frame)-400)) textShown1.attributedText = attrString1 self.view?