Reputation: 4506
When a certain value is selected from an actionsheet (I am using AcitonSheetPicker 3.0), I programmatically set a label and uitextview's hidden to false (so I show the item). By default it's not there.
I'd like to draw the user's attention to the newly added label and textview. Of course it would still be a required field, but I thought it might be a better user experience to briefly point out that it was added.
Since the action sheet is going to occupy the screen until the user makes a selection from the picker, the thing is they won't actually see the field as it becomes visible, so I thought it would be best to animate it in some way.
Are there any options at my disposal to briefly flash a textview, potentially in a certain color or style that might appealing but consistent with Apple design? I am using Swift and Xcode 6 and am targeting ios7 and 8 devices.
Thanks for your help!
Upvotes: 0
Views: 151
Reputation: 437
You can use an animation block and iterate a couple of flashes. Then play the animation over a period of 1 or 0.5 seconds, whatever fits best.
Animation block:
[UIView animateKeyframesWithDuration:0.5 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
for (int i=0; i<5; i++) {
[UIView addKeyframeWithRelativeStartTime:i*0.1 relativeDuration:0.25 animations:^{
if (i ==0 || i == 2){
//set to first colour
self.textfield.backgroundColor = [UIColor redColor];
}else if(i==4){
//reset to white colour or default textfield colour
self.textfield.backgroundColor = [UIColor whiteColor];
}else{
//set to second colour
self.textfield.backgroundColor = [UIColor yellowColor];
}];
}
}completion:nil];
Apple documentation: https://developer.apple.com/Library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/AnimatingViews/AnimatingViews.html
Upvotes: 1