-1

如何使用HSImageSidebarViewUIImage向 .png文件添加白色背景?

我曾尝试UIImageView在侧边栏上创建一个然后显示它,但不幸的是,该应用程序因 NSException 而崩溃。如果它们是 aUIImage而不是UIImageView.

4

2 回答 2

0

您将尝试此代码在 nib 上添加一个滚动视图并在 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 数组,其中包含许多文本,例如您想要多少视图。

于 2012-05-03T06:36:37.720 回答
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.
于 2012-05-03T07:12:30.670 回答