如何在UIImage中实现选框效果动画。
我有云的图像(320 * 480)。我需要从右边继续动画,没有任何滞后和消失。以下是html的示例。
http://www.quackit.com/html/codes/html_marquee_code.cfm
从顶部开始的第二个(连续滚动文字:)。
请帮忙
答案 0 :(得分:2)
UIImage *clouds = [UIImage imageNamed:@"Clouds"];
UIImageView *cloudView = [[UIImageView alloc] initWithImage:clouds];
CGRect origin = CGRectMake(320, 0, clouds.size.width, clouds.size.height);
CGRect destination = CGRectMake(0, 0, clouds.size.width, clouds.size.height);
cloudView.frame = origin;
[self.view addSubview:cloudView];
[UIView animateWithDuration:5 delay:0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear animations:^{
cloudView.frame = destination;
} completion:nil];
答案 1 :(得分:1)
这样做:
-(void)marqueeEffect
{
imgView.frame = CGRectMake(self.view.frame.origin.y,50,320,480); //right frame
//increase time duration as per requirement
[UIView animateWithDuration:3.0
delay: 0.0
options: UIViewAnimationCurveEaseOut
animations:^{
imgView.frame = CGRectMake(-imgview.frame.size.width,50,320,480); //left frame
}
completion:^(BOOL finished){
[self performSelector:@selector(marqueeEffect)];
}];
}
答案 2 :(得分:0)
尝试这个例子,它为UILABEL:
int x;
@synthesize label;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
label=[[UILabel alloc]initWithFrame:CGRectMake(300, 400, 150, 30)];
label.text=@"WWW.SONGS.PK";
label.backgroundColor=[UIColor clearColor];
x=300;
[NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(clickme) userInfo:nil repeats:YES];
}
-(void)clickme
{
x--;
label.frame=CGRectMake(x, 400, 150, 30);
if( x==-150)
{
x=300;
}
[self.view addSubview:label];
}