如果我执行以下操作,那么titleView
会很紧张:
UIImage * img =[UIImage imageNamed:@"isikota_small.png"];
UIImageView * uiImage= [[UIImageView alloc]initWithImage:img];
self.navigationItem.titleView = uiImage;
PO(self.navigationItem.titleView);
如果我做
UIImage * img =[UIImage imageNamed:@"isikota_small.png"];
UIImageView * uiImage= [[UIImageView alloc]initWithImage:img];
uiImage.frame = CGRectMake(0,0,66,33);
uiImage.autoresizingMask = UIViewAutoresizingFlexibleHeight;
//[self.navigationItem.titleView addAndResizeSubView:uiImage]; doesn't work
self.navigationItem.titleView = uiImage;
PO(self.navigationItem.titleView);
标题视图也会被拉伸。
如果我做:
UIImage * img =[UIImage imageNamed:@"isikota_small.png"];
UIImageView * uiImage= [[UIImageView alloc]initWithImage:img];
uiImage.frame = CGRectMake(0,0,66,33);
uiImage.autoresizingMask = UIViewAutoresizingFlexibleHeight;
//[self.navigationItem.titleView addAndResizeSubView:uiImage]; doesn't work
UIView * uiv = [[UIView alloc]init];
[uiv addSubview:uiImage];
uiv.frame = CGRectMake(127, 0, 66, 33);
uiv.autoresizingMask=UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
self.navigationItem.titleView = uiv;
PO(self.navigationItem.titleView);
苹果以某种方式将其更改uiv.frame
为CGRectMake(127, 6, 66, 33)
.
必须有一个优雅的解决方案。