[英]UIButton unresponsive when created programmatically and added to uiimageview
[英]UIImageView shows a discrete image when created programmatically
我遇到了問題。 我需要以編程方式創建UIImageView並將圖像添加到它。 但它有一些問題。 看看附帶的截圖。 第一個是普通圖像,如果我在xib(storyboard)中創建UIImageView並用我的圖像填充它。
下一個是具有一些不平滑線條的圖像(如離散或塊等)。
UIImageView *logoImg = [[UIImageView alloc]initWithFrame:CGRectMake(76.0f, 36.0f, 168.0f, 180.0f)];
logoImg.image = [[UIImage imageNamed:@"logo.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[self.view addSubview:logoImg];
我有這個徽標圖像的兩個版本( logo.png和logo@2x.png非視網膜/視網膜)。 logo.png是168x180像素。 logo@2x.png為336x360像素。
哪里錯了? 提前致謝 :)
我建議刪除項目中的兩個圖像,清理構建文件夾,重新啟動xCode並重新添加圖像。
不確定,但試試
myImageView.contentMode = UIViewContentModeScaleAspectFit;
這將顯示原始圖像,可能適合你:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.