- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat offset = scrollView.contentOffset.x; // here you will get the offset value
CGFloat value = offset/totalcontentsize;
// use 'value' for setting the textview alpha value
}
我只是添加邏輯如何處理。
或者您可以使用一個類別。就UIView的一類稱爲UIView的+看起來
@interface UIView (Looks)
-(void)fadeTail;
@end
@implementation UIView (Looks)
-(void)fadeTail
{
// it's used to fade away the bottom,
// perhaps of a slab of text, web view or similar
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.bounds;
gradient.colors = @[
(id)[[UIColor whiteColor] CGColor],
(id)[[UIColor clearColor] CGColor]
];
gradient.startPoint = CGPointMake(0.5, 0.93);
gradient.endPoint = CGPointMake(0.5, 1);
[self.layer setMask:gradient];
}
@end
例如使用(在這種情況下,在Web視圖
@property (strong) IBOutlet UIWebView *dossierBlock;
-(void)_fillMainArea
{
[self _loadBookImage];
NSString *longHtml = CLOUD.caMeeting[@"yourJsonTag"];
nullsafe(longHtml);
[self.dossierBlock longHtml baseURL:nil];
[self.dossierBlock fadeTail];
}
你可以平凡以同樣的方式做一個「fadeTop」。