- (void)viewDidLoad
{
NSLog(@"Welcome to Home Page");
[super viewDidLoad];
self.view.backgroundColor=[[UIColor alloc]initWithPatternImage:[UIImage imageNamed:@"bg-image.png"]];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)loadView {
CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];
scrollView.contentSize=CGSizeMake(1400, 100);
UIImageView *tempImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti01.png"]];
tempImageView2.frame=CGRectMake(10, 60, 200, 200);
[scrollView addSubview:tempImageView2];
UIImageView *tempImageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti02.png"]];
tempImageView3.frame=CGRectMake(240, 60, 200, 200);
[scrollView addSubview:tempImageView3];
UIImageView *tempImageView4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti03.png"]];
tempImageView4.frame=CGRectMake(470, 60, 200, 200);
[scrollView addSubview:tempImageView4];
UIImageView *tempImageView5 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti04.png"]];
tempImageView5.frame=CGRectMake(700, 60, 200, 200);
[scrollView addSubview:tempImageView5];
UIImageView *tempImageView6 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti05.png"]];
tempImageView6.frame=CGRectMake(930, 60, 200, 200);
[scrollView addSubview:tempImageView6];
UIImageView *tempImageView7 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sti06.png"]];
tempImageView7.frame=CGRectMake(1160, 60, 200, 200);
[scrollView addSubview:tempImageView7];
self.view=scrollView;
[scrollView addSubview:tempImageView2];
[scrollView addSubview:tempImageView3];
[scrollView addSubview:tempImageView4];
[scrollView addSubview:tempImageView5];
[scrollView addSubview:tempImageView6];
[scrollView addSubview:tempImageView7];
scrollView.userInteractionEnabled = YES;
btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(22, 100, 1800, 500);
// [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonTest:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:btn];
}
- (IBAction)buttonTest:(id)sender {
MSDescriptionpage *aSecondPageController = [[MSDescriptionpage alloc] initWithNibName:@"MSDescriptionpage" bundle:nil];
[self.navigationController pushViewController:aSecondPageController animated:YES];
[aSecondPageController release];
}
当我使用UISCROLLVIEW滚动内容时,如何设置背景图像固定。如何在ios.i中使用水平滚动视图时使用多种格式固定背景图像但不修复问题..
答案 0 :(得分:0)
修改强>
现在为这个.h文件添加滚动视图的IBOutlate
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
和.m文件
@synthesize scrollView;
并在xib中控制 - 从文件所有者拖动到scrollView以将IBOutlate分配给它
这将是这样的
现在