如何使用HSImageSidebarView将.png UIImage
文件添加到白色背景?
我尝试创建UIImageView
,然后在侧边栏上显示,但不幸的是,应用程序崩溃了NSException。如果这些图像文件是UIImage
而非UIImageView
,则有关如何在侧边栏上为图像文件添加白色背景的任何想法。
答案 0 :(得分:0)
您将尝试此代码在nib上添加一个scrollview并在viewdidload
上设置其内容CGFloat x = 20;
for (int i = 0;i<[playerScores count];i++) {
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(x, 10, 60, 60)];
view.backgroundColor=[UIColor blueColor];
NSString *text = [NSString stringWithFormat:[playerScores objectAtIndex:i]];
[view setText:text];
[yardsScrollView addSubview:view];
[myLabel release];
x = x+125;
}
PlayersScore是一个NSMutable数组,其中包含许多文本,例如您想要多少视图。
答案 1 :(得分:0)
@ objc-强迫
You will need to loop through the subviews to find whether it is of kind UIImage or UIImageView by this:
id object;
if([object isKindOfClass:[UIImage Class]]) {
//Do whatever u want to here by creating a new imageView on the top of this image
//Something like this:
UIImage *image =(UIImage*)object;
UIImageView *imgView=[[uiimageview alloc]initwithimage:image];
//Now perform the background view operations on imgView i.e. instance of UIImageView.
}
//Hope it works.