0

我想在我的一个视图控制器中根据 UILabel 的特定文本调整图像视图,但图像视图的框架永远不会改变。为简化起见,我现在只是尝试将图像视图的框架设置为硬编码值。我尝试了以下选项但没有成功:

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.lessonIcon.frame = CGRectMake(0, 0, 20, 20);
}

-(void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    self.lessonIcon.frame = CGRectMake(0, 0, 20, 20);
}

//This method is actually one I created.. it gets called in the modal completion callback
-(void)adjustFrame
{
    self.lessonIcon.frame = CGRectMake(0, 0, 20, 20);
}

在过去,像这样的问题是因为视图没有完成自己的布局,而且我与约束发生冲突。通常,一旦应用了 viewDidLayoutSubviews ,这将不再适用......但这次图像视图顽固地保持在它在情节提要中布置的位置。如何以编程方式更改此图像视图的框架?

4

0 回答 0