ios image and scrollview

21

Upload: aragorn-yeh

Post on 27-Jul-2015

284 views

Category:

Education


1 download

TRANSCRIPT

WINDOW & VIEW

UIWindow and UIView

Example

Position and Size

Bounds: (origin, size) in local view coordinates

Frame: (origin, size) in containing view’s coordinates

Center: view’s center in containing view’s coordinates

Creating & Manage Views

UIView *aView = [[UIView alloc]initWithFrame:[window frame]];

[window addSubview:aView];

- (void)removeFromSuperview;

- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;

- (void)bringSubviewToFront:(UIView *)view;

Add Image

UIImageView &imageView = [[UIImageView alloc] initWithFrame:

self.view.bounds];

imageView.image = [UIImage imageNamed:"0.png"];

imageView.contentMode = UIViewContentModeScaleAspectFit;

[self.view addSubview:imageView];

UISCROLLVIEW

UIScrollView

UIScrollView

Add ScrollView

UIScrollVview *scrollView = [[UIScrollView alloc] init];

scrollView.frame = self.view.bounds;

scrollView.contentSize = CGSizeMake(

self.view.frame.size.width*kPageNum, self.view.frame.size.height);

scrollView.pagingEnabled = YES;

[self.view addSubview:scrollView];

Homework

Image ScrollView App

– Email Project Folder .Zip