澎湃iPad上线版本

UIScrollView+PullScale.m 1.4KB

    #import "UIScrollView+PullScale.h" #import <objc/runtime.h> @interface UIScrollView () @end static char CorePullScaleImageViewKey; @implementation UIScrollView (PullScale) -(void)addPullScaleFuncInVC:(UIViewController *)vc imageUrl:(NSString *)imageUrl originalHeight:(CGFloat)originalHeight hasNavBar:(BOOL)hasNavBar{ CorePullScaleImageView *imageV=[[CorePullScaleImageView alloc] init]; self.imageV=imageV; imageV.hasNavBar=hasNavBar; imageV.originalHeight=originalHeight; imageV.imageUrl=imageUrl; imageV.vc=vc; CGFloat height=originalHeight; UIEdgeInsets contentInset=self.contentInset; contentInset.top+=height; self.contentInset=contentInset; CGPoint contentOffsett=self.contentOffset; contentOffsett.y-=height; self.contentOffset=contentOffsett; [self addSubview:imageV]; } - (void)resetPullScaleFrame:(CGRect)rect { self.imageV.frame = rect; } #pragma mark 使用运行时模拟成员变量:imageV -(void)setImageV:(CorePullScaleImageView *)imageV{ [self willChangeValueForKey:@"CorePullScaleImageViewKey"]; objc_setAssociatedObject(self, &CorePullScaleImageViewKey, imageV, OBJC_ASSOCIATION_ASSIGN); [self didChangeValueForKey:@"CorePullScaleImageViewKey"]; } -(CorePullScaleImageView *)imageV{ return objc_getAssociatedObject(self, &CorePullScaleImageViewKey); } @end