UIScrollView UIScrollViewDecelerationRateNormal
The rate of deceleration for a scrolling view.
const float UIScrollViewDecelerationRateNormal;
const float UIScrollViewDecelerationRateFast;
Constants
UIScrollViewDecelerationRateNormal
The default deceleration rate for a scroll view.
UIScrollViewDecelerationRateFast
A fast deceleration rate for a scroll view.
UIScrollView UIScrollViewDecelerationRateNormal example.
NSLog(@"1. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = UIScrollViewDecelerationRateNormal;
NSLog(@"2. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = UIScrollViewDecelerationRateFast;
NSLog(@"3. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = 0.7;
NSLog(@"4. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = 0.995;
NSLog(@"5. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = UIScrollViewDecelerationRateNormal;
NSLog(@"2. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = UIScrollViewDecelerationRateFast;
NSLog(@"3. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = 0.7;
NSLog(@"4. decelerationRate %f", scrollview.decelerationRate);
scrollview.decelerationRate = 0.995;
NSLog(@"5. decelerationRate %f", scrollview.decelerationRate);
Example of [UIScrollView UIScrollViewDecelerationRateNormal].
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
@try {
CGFloat decelerationRate = UIScrollViewDecelerationRateFast +(UIScrollViewDecelerationRateNormal - UIScrollViewDecelerationRateFast) * .52;
[self setValue:[NSValue valueWithCGSize:CGSizeMake(decelerationRate,decelerationRate)] forKey:@"_decelerationFactor"];
}
@catch (NSException *exception) {
// if they modify the way it works under us.
}
}
return self;
}
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
@try {
CGFloat decelerationRate = UIScrollViewDecelerationRateFast +(UIScrollViewDecelerationRateNormal - UIScrollViewDecelerationRateFast) * .52;
[self setValue:[NSValue valueWithCGSize:CGSizeMake(decelerationRate,decelerationRate)] forKey:@"_decelerationFactor"];
}
@catch (NSException *exception) {
// if they modify the way it works under us.
}
}
return self;
}
UIScrollView UIScrollViewDecelerationRateNormal example.
You can just turn up the deceleration rate very high. With an infinite rate, it would stop immediately. Try setting the rate to these constants:
scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
and
scrollView.decelerationRate = UIScrollViewDecelerationRateFast;
scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
and
scrollView.decelerationRate = UIScrollViewDecelerationRateFast;