How to move image in UIView

1. UIView define
2. UIScrollView define
3. UIImageView define
4. UIimage define

.h file

...
UISCrollView *scView;
...
@propery (nonautomic, retain) IBOutlet UIScrollView *scView;


.m file

..
@synthesize scView;
..

-(void)viewDidLoad
{
  UIImage *image = [UIImage imageNamed:@"test.png"];
  UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
  [scView addSubview:imageview];

  // repeat 1 second
  [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(imagemove:) userInfo:nil repeat:YES];
}

-(void)imagemove:(NSTimer *)timer {
  CGRect bounds;
  bounds = scView.bounds;
  bounds = CGRectMake(scView.bounds.origin.x - 1.0f, scView.bounds.origin.y, scView.bounds.size.width, scView.bounds.size.height);
  scView.bounds = bounds;
}

test Result is OK....

댓글

이 블로그의 인기 게시물

한글 2010 에서 Ctrl + F10 누르면 특수문자 안뜰 때

아이폰에서 RFID 사용하는 방법

VCC 와 GND 는 무엇일까?