Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        2年前关闭。
                                                                                            
                
        
我有2个UIImages和一个UISwitch,当开关打开时,图像1出现,而当开关关闭时,图像2出现...有什么想法吗?

最佳答案

如果您有一个名为myUISwitch的UISwitch和一个名为myUIImageView的UIImageView:

if(myUISwitch.on) {
    [myUIImageView setImage:[UIImage imageNamed:@"myOnImage.png"]];
}
else {
    [myUIImageView setImage:[UIImage imageNamed:@"myOffImage.png"]];
}


您可以将此代码放在通过更改UISwitch触发的函数中...

关于iphone - 以编程方式更改UIImage ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2507851/

10-13 03:43