我试图UIImageView
viewDidLoad
闪烁.hidden=YES
。我不确定最好的办法是什么。我尝试使用.hidden=NO
和{{1}}的循环,但这似乎是一种不好的方法。我需要一些适当的建议。
答案 0 :(得分:5)
试试这个:
-(void)blink:(UIView*)view count:(int) count
{
if(count == 0)
{
return;
}
[UIView animateWithDuration:0.2 animations:^{
view.alpha = 0.0;
} completion:^(BOOL finished){
[UIView animateWithDuration:0.2 animations:^{
view.alpha = 1.0;
} completion:^(BOOL finished){
[self blink:view count:count-1];
}];
}];
}
或者如果你想让它永远眨眼,试试这个:
-(void)blinkForever:(UIView*)view
{
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{
view.alpha = 0.0;
} completion:nil];
}
答案 1 :(得分:4)
如果你只想隐藏和显示然后使用NStimer为此目的 像这样的东西
<。>在.h文件中添加此属性 @property(非原子,强)NSTimer *计时器;if( url.search(".png") != -1 || url.search(".jpg") != -1 || url.search(".jpeg") != -1 || url.search(".tif") != -1 || url.search(".tiff") != -1){
<强>夫特强>:
public function e() {
$criteria = new \Doctrine\Common\Collections\Criteria();
$d=date('Y-m-d'); // i think your error is here
$timestamp = strtotime($d); //here
$date=date('Y-m-d',$timestamp); //and here
$d = //place here where the date is coming from
$date = date('Y-m-d', strtotime($d)); //formatter of date
$criteria->where($criteria->expr()->lt('date',$date));
$result=$this->em->getRepository('OCUserBundle:Tranche')->matching($criteria);
return count($result);
}
但UIImageView也可以为不同的图像添加动画效果 像这样的东西
- (void)onTimerEvent:(NSTimer*)timer
{
self.imageView.hidden = !self.imageView.hidden;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(onTimerEvent:) userInfo:nil repeats:YES];
}
答案 2 :(得分:3)
您可以使用UIImageView的alpha。以下是一个示例(只需在startAnim
中调用viewDidLoad
):
static NSInteger count = 0;
static NSInteger maxBlind = 10;
- (void)startAnim{
CGFloat animDuration = 0.5f;
[UIView animateWithDuration:animDuration
animations:^{
self.myImageView.alpha = 0.f;
} completion:^(BOOL finished) {
[UIView animateWithDuration:animDuration
animations:^{
self.myImageView.alpha = 1.f;
} completion:^(BOOL finished) {
if (count < maxBlind){
[self startAnim];
count++;
}
}];
}];
}
答案 3 :(得分:1)
使用UIImageView动画,您可以放入空图像或空白图像:
http://spin.atomicobject.com/2014/08/27/animate-images-uiimageview-completion-handler/
享受