【发布时间】:2014-03-20 08:01:55
【问题描述】:
我正在尝试叠加两个图像并将文本放在我拥有的视图的顶部。我在 ios7 中完美运行。这是结果的屏幕截图
现在渐变只是在我的布局中看到的另一个图像顶部的图像
这很好用,除非我在手机上使用 ios6 进行测试。然后一切都变得疯狂,就像这里看到的那样。 *我实际上已经删除了渐变层并再次运行应用程序,背景图像保持相同大小(大约是应有大小的一半)。
如您所见,背景图片只有应有的一半,第二张图片没有叠加。我已经为此工作了 5 个小时,但似乎找不到有效的解决方案。
这里是设置背景图片的代码
-(void) SetDetails
{
if(_curInfo)
{
_lblTopName.text = _curInfo.company_name;
if(!_curInfo.img)
{
showActivity(self);
dispatch_queue_t aQueue1 = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(aQueue1, ^{
_curInfo.img = getImageFromURL([NSString stringWithFormat:@"%@%@", g_serverUrl, _curInfo.imgPath]);
dispatch_async(dispatch_get_main_queue(), ^{
hideActivity();
[_imgCompany setImage:_curInfo.img];
});
});
}
[_imgCompany setImage:_curInfo.img];
/* FIX IMAGE SIZE */
_imgCompany.contentMode=UIViewContentModeScaleAspectFill;
CGRect photoFrame = _imgCompany.frame;
photoFrame.size = CGSizeMake(320, 180);
_imgCompany.frame=photoFrame;
[_imgCompany setClipsToBounds:YES];
_lblDistance.text = [NSString stringWithFormat:@"%.2f miles", _curInfo.distance];
_lblReward.text=_curInfo.reward;
CGFloat scrollViewHeight = 0.0f;
for (UIView* view in scroller.subviews)
{
scrollViewHeight += view.frame.size.height;
}
[scroller setContentSize:(CGSizeMake(320, scrollViewHeight))];
}
}
非常感谢任何帮助。我也不反对在图像上绘制渐变。
附加信息:
这是我设置两个图像视图的方法。
【问题讨论】:
标签: ios objective-c