0

Getting this from NSMutableAttributedString using the NSLinkAttributeName attribute.

Using a html file for the link name. How to make the text area bigger.

-(NSMutableAttributedString *)attributedStringForLink:(NSString *)fullString
                                    attributedString :(NSMutableAttributedString  *)attributedString
                                             link:(NSString *)linkString
                                             path:(NSString *)pathString
                                             font:(UIFont *)textFont
                                            color:(UIColor *)textColor
                                        alignment:(NSTextAlignment)textAlign
{
    NSMutableAttributedString *attString;
    if(attributedString) {
        attString = attributedString;
    } else {
        attString = [[NSMutableAttributedString alloc]initWithString:fullString];
    }
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setAlignment:textAlign];
    [paragraphStyle setLineBreakMode:NSLineBreakByWordWrapping];
    NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle,
                                           NSFontAttributeName:textFont,
                                NSForegroundColorAttributeName:textColor};

    NSRange range = [fullString rangeOfString:linkString];
    [attString addAttributes:attributes range:range];
    [attString addAttribute:NSLinkAttributeName value:pathString range:range];
    [attString addAttribute:NSForegroundColorAttributeName value:textColor range:range];

    return attString;
}
  • What is your question exactly? "How to make the text area bigger"? Change the font using a new font size? – Larme Apr 21 '20 at 14:53

1 Answers1

0

Sorry about the really bad prob description. Was using an NSAttributedString with a LINK and it was producing a really small result. Turns out it was my own view controller with a small UIWebView. Create a new UIViewController containing a UITextView containing a UIWebView. Add the following delegate method:

-(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL
         inRange:(NSRange)characterRange
     interaction:(UITextItemInteraction)interaction
{
    if([[URL absoluteString] isEqualToString:@""]) {
        return NO;
    }

    WebViewController *viewController = [[WebViewController alloc]init];

    viewController.pathString = [URL absoluteString];
    [self presentViewController:viewController animated:YES completion:nil];

    return NO;
}