Skip to content

Instantly share code, notes, and snippets.

@NaStillmatic
Last active November 10, 2017 07:29
Show Gist options
  • Save NaStillmatic/13dc11befaa6c9fd42a555b5d44ff4b2 to your computer and use it in GitHub Desktop.
Save NaStillmatic/13dc11befaa6c9fd42a555b5d44ff4b2 to your computer and use it in GitHub Desktop.
[Objective-C] UITextView에 커스텀 링크 연결
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *textView;
@end
#import "UITextView+CustomLink.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSString *strAgreement = @"서비스약관, 유료이용약관, 개인정보 취급방침에 동의합니다.";
NSArray *textArray =@[@"서비스약관", @"유료이용약관", @"개인정보 취급방침"];
NSArray *urlArray = @[@"agreement://0", @"agreement://1", @"agreement://2"];
[self.textView setCustomLink:strAgreement fontSize:14 linkTextColor:[UIColor redColor] linkUnderLineColor:[UIColor redColor] stringArray:textArray URLArray:urlArray];
}
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
if ([URL.scheme isEqualToString:@"agreement"])
{
NSLog(@"select Link = %ld", URL.host.integerValue);
return NO;
}
return YES;
}
@NaStillmatic
Copy link
Author

2017-11-10 03 55 15 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment