2
基本的な質問だとは思いますが、まだ動作する回答は見つけられませんでした。私はPDF文脈への道を描くことによってPDFファイルを作成しています。そして、図面上のさまざまな領域を外部コンテンツ(http://bla.bla)へのハイパーリンクにしたいと思います。私は交差していない矩形であっても満足しています。誰でもそのことを知っていますか?プログラムでPDFファイルにリンクを作成する
基本的な質問だとは思いますが、まだ動作する回答は見つけられませんでした。私はPDF文脈への道を描くことによってPDFファイルを作成しています。そして、図面上のさまざまな領域を外部コンテンツ(http://bla.bla)へのハイパーリンクにしたいと思います。私は交差していない矩形であっても満足しています。誰でもそのことを知っていますか?プログラムでPDFファイルにリンクを作成する
この質問に対する回答を確認してください:Embed hyperlink in PDF using Core Graphics on iOS。
- (void) drawTextLink:(NSString *) text inFrame:(CGRect) frameRect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGAffineTransform ctm = CGContextGetCTM(context);
// Translate the origin to the bottom left.
// Notice that 842 is the size of the PDF page.
CGAffineTransformTranslate(ctm, 0.0, 842);
// Flip the handedness of the coordinate system back to right handed.
CGAffineTransformScale(ctm, 1.0, -1.0);
// Convert the update rectangle to the new coordiante system.
CGRect xformRect = CGRectApplyAffineTransform(frameRect, ctm);
NSURL *url = [NSURL URLWithString:text];
UIGraphicsSetPDFContextURLForRect(url, xformRect);
CGContextSaveGState(context);
NSDictionary *attributesDict;
NSMutableAttributedString *attString;
NSNumber *underline = [NSNumber numberWithInt:NSUnderlineStyleSingle];
attributesDict = @{NSUnderlineStyleAttributeName : underline, NSForegroundColorAttributeName : [UIColor blueColor]};
attString = [[NSMutableAttributedString alloc] initWithString:url.absoluteString attributes:attributesDict];
[attString drawInRect:frameRect];
CGContextRestoreGState(context);
}
ありがとう!8morechr方法drawTextLink方法でframeRectを渡す方法 – user1258240
? – AppAspect