如何更改 MKAnnotation 标题和副标题的字体大小 [英] how can I change font size on MKAnnotation title and subtitle
问题描述
我如何更改 MKAnnotation 标题和副标题这是我的代码
how can I change MKAnnotation title and subtitle this is my code
Newclass *ann1 = [[Newclass alloc] init];
ann1.title = namef1;
ann1.subtitle = @"";
ann1.coordinate = place1.center;
[mapView addAnnotation: ann1];
我搜索使用
UIFont *size = [UIFont systemFontOfSize:17];
CGSize textsize = [ann1.title sizeWithAttributes:@{NSFontAttributeName:size}];
但是构建此代码它显示未使用的变量 textsize
but Build this code it shown un used variable textsize
推荐答案
MKAnnotation
和 MKAnnotationView
之间有明显的区别.您将无法以您希望的方式自定义订阅 MKAnnotationProtocol 的对象,因为 MKAnnotation
协议仅要求对象维护变量以存储稍后将由 MKAnnotation
绘制的信息code>MKAnnotationView 对象.
There is a clear distinction between a MKAnnotation
and a MKAnnotationView
. You won't be able to customize an object that subscribes to the MKAnnotationProtocol in such a way that you hope because the MKAnnotation
protocol only asks objects to maintain variables to store information that will be later drawn by an MKAnnotationView
object.
我建议您编写一个自定义 MKAnnotationView
子类,其中包含自定义字体、大小和任何其他适用于您希望注释外观的内容.
I recommend you write a custom MKAnnotationView
subclass that contains the custom fonts, sizes & anything else applicable to how you'd like the annotation to look.
这篇关于如何更改 MKAnnotation 标题和副标题的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!