├── .gitignore ├── Class ├── FloatView.h └── FloatView.m ├── FloatView ├── FloatView.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── FloatView │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── FloatBonus.imageset │ │ │ ├── Contents.json │ │ │ ├── FloatBonus@2x.png │ │ │ └── FloatBonus@3x.png │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── FloatView.h │ ├── FloatView.m │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── FloatViewTests │ ├── FloatViewTests.m │ └── Info.plist └── FloatViewUITests │ ├── FloatViewUITests.m │ └── Info.plist ├── LICENSE ├── README.md └── screenshots └── FloatView.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /Class/FloatView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FloatView.h 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // 停留方式 12 | typedef NS_ENUM(NSInteger, StayMode) { 13 | // 停靠左右两侧 14 | STAYMODE_LEFTANDRIGHT = 0, 15 | // 停靠左侧 16 | STAYMODE_LEFT = 1, 17 | // 停靠右侧 18 | STAYMODE_RIGHT = 2 19 | }; 20 | 21 | @interface FloatView : UIImageView 22 | 23 | /** 悬浮图片停留的方式(默认为STAYMODE_LEFTANDRIGHT) */ 24 | @property (nonatomic, assign) StayMode stayMode; 25 | 26 | /** 悬浮图片停留时的透明度(stayAlpha >= 0,1:不透明,默认为不透明) */ 27 | @property (nonatomic, assign) CGFloat stayAlpha; 28 | 29 | /** 悬浮图片左右边距(默认5)*/ 30 | @property (nonatomic, assign) CGFloat stayEdgeDistance; 31 | 32 | /** 悬浮图片停靠的动画事件(默认0.3秒)*/ 33 | @property (nonatomic, assign) CGFloat stayAnimateTime; 34 | 35 | /** 设置简单的轻点 block事件 */ 36 | - (void)setTapActionWithBlock:(void (^)(void))block; 37 | 38 | /** 根据 imageName 改变FloatView的image */ 39 | - (void)setImageWithName:(NSString *)imageName; 40 | 41 | /** 当滚动的时候悬浮图片居中在屏幕边缘 */ 42 | - (void)facingScreenBorderWhenScrolling; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Class/FloatView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FloatView.m 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import "FloatView.h" 10 | #import 11 | 12 | #define NavBarBottom 64 13 | #define TabBarHeight 49 14 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 15 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 16 | 17 | static char kActionHandlerTapBlockKey; 18 | static char kActionHandlerTapGestureKey; 19 | 20 | @implementation FloatView 21 | 22 | - (instancetype)initWithImage:(UIImage *)image 23 | { 24 | if (self = [super initWithImage:image]) { 25 | self.userInteractionEnabled = YES; 26 | self.stayEdgeDistance = 5; 27 | self.stayAnimateTime = 0.3; 28 | [self initStayLocation]; 29 | } 30 | return self; 31 | } 32 | 33 | - (instancetype)initWithFrame:(CGRect)frame 34 | { 35 | if (self = [super initWithFrame:frame]) { 36 | self = [[FloatView alloc] initWithImage:[UIImage imageNamed:@"FloatBonus"]]; 37 | self.userInteractionEnabled = YES; 38 | self.stayEdgeDistance = 5; 39 | self.stayAnimateTime = 0.3; 40 | [self initStayLocation]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 46 | { 47 | // 先让悬浮图片的alpha为1 48 | self.alpha = 1; 49 | // 获取手指当前的点 50 | UITouch * touch = [touches anyObject]; 51 | CGPoint curPoint = [touch locationInView:self]; 52 | 53 | CGPoint prePoint = [touch previousLocationInView:self]; 54 | 55 | // x方向移动的距离 56 | CGFloat deltaX = curPoint.x - prePoint.x; 57 | CGFloat deltaY = curPoint.y - prePoint.y; 58 | CGRect frame = self.frame; 59 | frame.origin.x += deltaX; 60 | frame.origin.y += deltaY; 61 | self.frame = frame; 62 | } 63 | 64 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 65 | { 66 | [self moveStay]; 67 | // 这里可以设置过几秒,alpha减小 68 | // __weak typeof(self) weakSelf = self; 69 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 70 | // [pThis animateHidden]; 71 | }); 72 | } 73 | 74 | #pragma mark - 设置浮动图片的初始位置 75 | - (void)initStayLocation 76 | { 77 | CGRect frame = self.frame; 78 | CGFloat stayWidth = frame.size.width; 79 | CGFloat initX = kScreenWidth - self.stayEdgeDistance - stayWidth; 80 | CGFloat initY = (kScreenHeight - NavBarBottom - TabBarHeight) * (2.0 / 3.0) + NavBarBottom; 81 | frame.origin.x = initX; 82 | frame.origin.y = initY; 83 | self.frame = frame; 84 | } 85 | 86 | #pragma mark - 根据 stayModel 来移动悬浮图片 87 | - (void)moveStay 88 | { 89 | bool isLeft = [self judgeLocationIsLeft]; 90 | switch (_stayMode) { 91 | case STAYMODE_LEFTANDRIGHT: 92 | { 93 | [self moveToBorder:isLeft]; 94 | } 95 | break; 96 | case STAYMODE_LEFT: 97 | { 98 | [self moveToBorder:YES]; 99 | } 100 | break; 101 | case STAYMODE_RIGHT: 102 | { 103 | [self moveToBorder:NO]; 104 | } 105 | break; 106 | default: 107 | break; 108 | } 109 | } 110 | 111 | #pragma mark - 设置悬浮图片以动画的方式隐藏 112 | - (void)animateHidden 113 | { 114 | __weak typeof(self) weakSelf = self; 115 | [UIView animateWithDuration:0.5 animations:^{ 116 | __strong typeof(self) pThis = weakSelf; 117 | pThis.alpha = _stayAlpha; 118 | }]; 119 | } 120 | 121 | #pragma mark - 移动到屏幕边缘 122 | - (void)moveToBorder:(BOOL)isLeft 123 | { 124 | CGRect frame = self.frame; 125 | CGFloat destinationX; 126 | if (isLeft) { 127 | destinationX = self.stayEdgeDistance; 128 | } 129 | else { 130 | CGFloat stayWidth = frame.size.width; 131 | destinationX = kScreenWidth - self.stayEdgeDistance - stayWidth; 132 | } 133 | frame.origin.x = destinationX; 134 | frame.origin.y = [self moveSafeLocationY]; 135 | __weak typeof(self) weakSelf = self; 136 | [UIView animateWithDuration:_stayAnimateTime animations:^{ 137 | __strong typeof(self) pThis = weakSelf; 138 | pThis.frame = frame; 139 | }]; 140 | } 141 | 142 | #pragma mark - 设置悬浮图片不高于屏幕顶端,不低于屏幕底端 143 | - (CGFloat)moveSafeLocationY 144 | { 145 | CGRect frame = self.frame; 146 | CGFloat stayHeight = frame.size.height; 147 | // 当前view的y值 148 | CGFloat curY = self.frame.origin.y; 149 | CGFloat destinationY = frame.origin.y; 150 | // 悬浮图片的最顶端Y值 151 | CGFloat stayMostTopY = NavBarBottom + _stayEdgeDistance; 152 | if (curY <= stayMostTopY) { 153 | destinationY = stayMostTopY; 154 | } 155 | // 悬浮图片的底端Y值 156 | CGFloat stayMostBottomY = kScreenHeight - TabBarHeight - _stayEdgeDistance - stayHeight; 157 | if (curY >= stayMostBottomY) { 158 | destinationY = stayMostBottomY; 159 | } 160 | return destinationY; 161 | } 162 | 163 | #pragma mark - 判断当前view是否在父界面的左边 164 | - (bool)judgeLocationIsLeft 165 | { 166 | // 手机屏幕中间位置x值 167 | CGFloat middleX = [UIScreen mainScreen].bounds.size.width / 2.0; 168 | // 当前view的x值 169 | CGFloat curX = self.frame.origin.x; 170 | if (curX <= middleX) { 171 | return YES; 172 | } else { 173 | return NO; 174 | } 175 | } 176 | 177 | #pragma mark - 当滚动的时候悬浮图片居中在屏幕边缘 178 | - (void)facingScreenBorderWhenScrolling 179 | { 180 | bool isLeft = [self judgeLocationIsLeft]; 181 | [self moveStayToMiddleInScreenBorder:isLeft]; 182 | } 183 | 184 | // 悬浮图片居中在屏幕边缘 185 | - (void)moveStayToMiddleInScreenBorder:(BOOL)isLeft 186 | { 187 | CGRect frame = self.frame; 188 | CGFloat stayWidth = frame.size.width; 189 | CGFloat destinationX; 190 | if (isLeft == YES) { 191 | destinationX = - stayWidth/2; 192 | } 193 | else { 194 | destinationX = kScreenWidth - stayWidth + stayWidth/2; 195 | } 196 | frame.origin.x = destinationX; 197 | __weak typeof(self) weakSelf = self; 198 | [UIView animateWithDuration:0.2 animations:^{ 199 | __strong typeof(self) pThis = weakSelf; 200 | pThis.frame = frame; 201 | }]; 202 | } 203 | 204 | #pragma mark - 设置简单的轻点 block事件 205 | - (void)setTapActionWithBlock:(void (^)(void))block 206 | { 207 | UITapGestureRecognizer *gesture = objc_getAssociatedObject(self, &kActionHandlerTapGestureKey); 208 | 209 | if (!gesture) 210 | { 211 | gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(__handleActionForTapGesture:)]; 212 | [self addGestureRecognizer:gesture]; 213 | objc_setAssociatedObject(self, &kActionHandlerTapGestureKey, gesture, OBJC_ASSOCIATION_RETAIN); 214 | } 215 | 216 | objc_setAssociatedObject(self, &kActionHandlerTapBlockKey, block, OBJC_ASSOCIATION_COPY); 217 | } 218 | 219 | - (void)__handleActionForTapGesture:(UITapGestureRecognizer *)gesture 220 | { 221 | if (gesture.state == UIGestureRecognizerStateRecognized) 222 | { 223 | void(^action)(void) = objc_getAssociatedObject(self, &kActionHandlerTapBlockKey); 224 | if (action) 225 | { 226 | // 先让悬浮图片的alpha为1 227 | self.alpha = 1; 228 | [self moveStay]; 229 | action(); 230 | } 231 | } 232 | } 233 | 234 | #pragma mark - getter / setter 235 | - (void)setStayAlpha:(CGFloat)stayAlpha 236 | { 237 | if (stayAlpha <= 0) { 238 | stayAlpha = 1; 239 | } 240 | _stayAlpha = stayAlpha; 241 | } 242 | 243 | - (void)setImageWithName:(NSString *)imageName 244 | { 245 | self.image = [UIImage imageNamed:imageName]; 246 | } 247 | 248 | @end 249 | -------------------------------------------------------------------------------- /FloatView/FloatView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A8947621E7AE73D00667E81 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8947611E7AE73D00667E81 /* main.m */; }; 11 | 1A8947651E7AE73D00667E81 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8947641E7AE73D00667E81 /* AppDelegate.m */; }; 12 | 1A8947681E7AE73E00667E81 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8947671E7AE73E00667E81 /* ViewController.m */; }; 13 | 1A89476B1E7AE73E00667E81 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A8947691E7AE73E00667E81 /* Main.storyboard */; }; 14 | 1A89476D1E7AE73E00667E81 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A89476C1E7AE73E00667E81 /* Assets.xcassets */; }; 15 | 1A8947701E7AE73E00667E81 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1A89476E1E7AE73E00667E81 /* LaunchScreen.storyboard */; }; 16 | 1A89477B1E7AE73E00667E81 /* FloatViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A89477A1E7AE73E00667E81 /* FloatViewTests.m */; }; 17 | 1A8947861E7AE73E00667E81 /* FloatViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8947851E7AE73E00667E81 /* FloatViewUITests.m */; }; 18 | 1AD3D4761E7BD1A200DC965F /* FloatView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AD3D4751E7BD1A200DC965F /* FloatView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 1A8947771E7AE73E00667E81 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 1A8947551E7AE73D00667E81 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 1A89475C1E7AE73D00667E81; 27 | remoteInfo = FloatView; 28 | }; 29 | 1A8947821E7AE73E00667E81 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 1A8947551E7AE73D00667E81 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 1A89475C1E7AE73D00667E81; 34 | remoteInfo = FloatView; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 1A89475D1E7AE73D00667E81 /* FloatView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FloatView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 1A8947611E7AE73D00667E81 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 1A8947631E7AE73D00667E81 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 1A8947641E7AE73D00667E81 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 1A8947661E7AE73D00667E81 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | 1A8947671E7AE73E00667E81 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | 1A89476A1E7AE73E00667E81 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 1A89476C1E7AE73E00667E81 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 1A89476F1E7AE73E00667E81 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 1A8947711E7AE73E00667E81 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 1A8947761E7AE73E00667E81 /* FloatViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FloatViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 1A89477A1E7AE73E00667E81 /* FloatViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FloatViewTests.m; sourceTree = ""; }; 51 | 1A89477C1E7AE73E00667E81 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 1A8947811E7AE73E00667E81 /* FloatViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FloatViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 1A8947851E7AE73E00667E81 /* FloatViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FloatViewUITests.m; sourceTree = ""; }; 54 | 1A8947871E7AE73E00667E81 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 1AD3D4741E7BD1A200DC965F /* FloatView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatView.h; sourceTree = ""; }; 56 | 1AD3D4751E7BD1A200DC965F /* FloatView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FloatView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 1A89475A1E7AE73D00667E81 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 1A8947731E7AE73E00667E81 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 1A89477E1E7AE73E00667E81 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 1A8947541E7AE73D00667E81 = { 85 | isa = PBXGroup; 86 | children = ( 87 | 1A89475F1E7AE73D00667E81 /* FloatView */, 88 | 1A8947791E7AE73E00667E81 /* FloatViewTests */, 89 | 1A8947841E7AE73E00667E81 /* FloatViewUITests */, 90 | 1A89475E1E7AE73D00667E81 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | 1A89475E1E7AE73D00667E81 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 1A89475D1E7AE73D00667E81 /* FloatView.app */, 98 | 1A8947761E7AE73E00667E81 /* FloatViewTests.xctest */, 99 | 1A8947811E7AE73E00667E81 /* FloatViewUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | 1A89475F1E7AE73D00667E81 /* FloatView */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 1AD3D4741E7BD1A200DC965F /* FloatView.h */, 108 | 1AD3D4751E7BD1A200DC965F /* FloatView.m */, 109 | 1A8947631E7AE73D00667E81 /* AppDelegate.h */, 110 | 1A8947641E7AE73D00667E81 /* AppDelegate.m */, 111 | 1A8947661E7AE73D00667E81 /* ViewController.h */, 112 | 1A8947671E7AE73E00667E81 /* ViewController.m */, 113 | 1A8947691E7AE73E00667E81 /* Main.storyboard */, 114 | 1A89476C1E7AE73E00667E81 /* Assets.xcassets */, 115 | 1A89476E1E7AE73E00667E81 /* LaunchScreen.storyboard */, 116 | 1A8947711E7AE73E00667E81 /* Info.plist */, 117 | 1A8947601E7AE73D00667E81 /* Supporting Files */, 118 | ); 119 | path = FloatView; 120 | sourceTree = ""; 121 | }; 122 | 1A8947601E7AE73D00667E81 /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 1A8947611E7AE73D00667E81 /* main.m */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | 1A8947791E7AE73E00667E81 /* FloatViewTests */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 1A89477A1E7AE73E00667E81 /* FloatViewTests.m */, 134 | 1A89477C1E7AE73E00667E81 /* Info.plist */, 135 | ); 136 | path = FloatViewTests; 137 | sourceTree = ""; 138 | }; 139 | 1A8947841E7AE73E00667E81 /* FloatViewUITests */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 1A8947851E7AE73E00667E81 /* FloatViewUITests.m */, 143 | 1A8947871E7AE73E00667E81 /* Info.plist */, 144 | ); 145 | path = FloatViewUITests; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | 1A89475C1E7AE73D00667E81 /* FloatView */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 1A89478A1E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatView" */; 154 | buildPhases = ( 155 | 1A8947591E7AE73D00667E81 /* Sources */, 156 | 1A89475A1E7AE73D00667E81 /* Frameworks */, 157 | 1A89475B1E7AE73D00667E81 /* Resources */, 158 | ); 159 | buildRules = ( 160 | ); 161 | dependencies = ( 162 | ); 163 | name = FloatView; 164 | productName = FloatView; 165 | productReference = 1A89475D1E7AE73D00667E81 /* FloatView.app */; 166 | productType = "com.apple.product-type.application"; 167 | }; 168 | 1A8947751E7AE73E00667E81 /* FloatViewTests */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = 1A89478D1E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatViewTests" */; 171 | buildPhases = ( 172 | 1A8947721E7AE73E00667E81 /* Sources */, 173 | 1A8947731E7AE73E00667E81 /* Frameworks */, 174 | 1A8947741E7AE73E00667E81 /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | 1A8947781E7AE73E00667E81 /* PBXTargetDependency */, 180 | ); 181 | name = FloatViewTests; 182 | productName = FloatViewTests; 183 | productReference = 1A8947761E7AE73E00667E81 /* FloatViewTests.xctest */; 184 | productType = "com.apple.product-type.bundle.unit-test"; 185 | }; 186 | 1A8947801E7AE73E00667E81 /* FloatViewUITests */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 1A8947901E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatViewUITests" */; 189 | buildPhases = ( 190 | 1A89477D1E7AE73E00667E81 /* Sources */, 191 | 1A89477E1E7AE73E00667E81 /* Frameworks */, 192 | 1A89477F1E7AE73E00667E81 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | 1A8947831E7AE73E00667E81 /* PBXTargetDependency */, 198 | ); 199 | name = FloatViewUITests; 200 | productName = FloatViewUITests; 201 | productReference = 1A8947811E7AE73E00667E81 /* FloatViewUITests.xctest */; 202 | productType = "com.apple.product-type.bundle.ui-testing"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | 1A8947551E7AE73D00667E81 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastUpgradeCheck = 0810; 211 | ORGANIZATIONNAME = wangrui; 212 | TargetAttributes = { 213 | 1A89475C1E7AE73D00667E81 = { 214 | CreatedOnToolsVersion = 8.1; 215 | DevelopmentTeam = 652U6LDTX4; 216 | ProvisioningStyle = Automatic; 217 | }; 218 | 1A8947751E7AE73E00667E81 = { 219 | CreatedOnToolsVersion = 8.1; 220 | DevelopmentTeam = 652U6LDTX4; 221 | ProvisioningStyle = Automatic; 222 | TestTargetID = 1A89475C1E7AE73D00667E81; 223 | }; 224 | 1A8947801E7AE73E00667E81 = { 225 | CreatedOnToolsVersion = 8.1; 226 | DevelopmentTeam = 652U6LDTX4; 227 | ProvisioningStyle = Automatic; 228 | TestTargetID = 1A89475C1E7AE73D00667E81; 229 | }; 230 | }; 231 | }; 232 | buildConfigurationList = 1A8947581E7AE73D00667E81 /* Build configuration list for PBXProject "FloatView" */; 233 | compatibilityVersion = "Xcode 3.2"; 234 | developmentRegion = English; 235 | hasScannedForEncodings = 0; 236 | knownRegions = ( 237 | en, 238 | Base, 239 | ); 240 | mainGroup = 1A8947541E7AE73D00667E81; 241 | productRefGroup = 1A89475E1E7AE73D00667E81 /* Products */; 242 | projectDirPath = ""; 243 | projectRoot = ""; 244 | targets = ( 245 | 1A89475C1E7AE73D00667E81 /* FloatView */, 246 | 1A8947751E7AE73E00667E81 /* FloatViewTests */, 247 | 1A8947801E7AE73E00667E81 /* FloatViewUITests */, 248 | ); 249 | }; 250 | /* End PBXProject section */ 251 | 252 | /* Begin PBXResourcesBuildPhase section */ 253 | 1A89475B1E7AE73D00667E81 /* Resources */ = { 254 | isa = PBXResourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | 1A8947701E7AE73E00667E81 /* LaunchScreen.storyboard in Resources */, 258 | 1A89476D1E7AE73E00667E81 /* Assets.xcassets in Resources */, 259 | 1A89476B1E7AE73E00667E81 /* Main.storyboard in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | 1A8947741E7AE73E00667E81 /* Resources */ = { 264 | isa = PBXResourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | 1A89477F1E7AE73E00667E81 /* Resources */ = { 271 | isa = PBXResourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXResourcesBuildPhase section */ 278 | 279 | /* Begin PBXSourcesBuildPhase section */ 280 | 1A8947591E7AE73D00667E81 /* Sources */ = { 281 | isa = PBXSourcesBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | 1A8947681E7AE73E00667E81 /* ViewController.m in Sources */, 285 | 1A8947651E7AE73D00667E81 /* AppDelegate.m in Sources */, 286 | 1A8947621E7AE73D00667E81 /* main.m in Sources */, 287 | 1AD3D4761E7BD1A200DC965F /* FloatView.m in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | 1A8947721E7AE73E00667E81 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 1A89477B1E7AE73E00667E81 /* FloatViewTests.m in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | 1A89477D1E7AE73E00667E81 /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 1A8947861E7AE73E00667E81 /* FloatViewUITests.m in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | /* End PBXSourcesBuildPhase section */ 308 | 309 | /* Begin PBXTargetDependency section */ 310 | 1A8947781E7AE73E00667E81 /* PBXTargetDependency */ = { 311 | isa = PBXTargetDependency; 312 | target = 1A89475C1E7AE73D00667E81 /* FloatView */; 313 | targetProxy = 1A8947771E7AE73E00667E81 /* PBXContainerItemProxy */; 314 | }; 315 | 1A8947831E7AE73E00667E81 /* PBXTargetDependency */ = { 316 | isa = PBXTargetDependency; 317 | target = 1A89475C1E7AE73D00667E81 /* FloatView */; 318 | targetProxy = 1A8947821E7AE73E00667E81 /* PBXContainerItemProxy */; 319 | }; 320 | /* End PBXTargetDependency section */ 321 | 322 | /* Begin PBXVariantGroup section */ 323 | 1A8947691E7AE73E00667E81 /* Main.storyboard */ = { 324 | isa = PBXVariantGroup; 325 | children = ( 326 | 1A89476A1E7AE73E00667E81 /* Base */, 327 | ); 328 | name = Main.storyboard; 329 | sourceTree = ""; 330 | }; 331 | 1A89476E1E7AE73E00667E81 /* LaunchScreen.storyboard */ = { 332 | isa = PBXVariantGroup; 333 | children = ( 334 | 1A89476F1E7AE73E00667E81 /* Base */, 335 | ); 336 | name = LaunchScreen.storyboard; 337 | sourceTree = ""; 338 | }; 339 | /* End PBXVariantGroup section */ 340 | 341 | /* Begin XCBuildConfiguration section */ 342 | 1A8947881E7AE73E00667E81 /* Debug */ = { 343 | isa = XCBuildConfiguration; 344 | buildSettings = { 345 | ALWAYS_SEARCH_USER_PATHS = NO; 346 | CLANG_ANALYZER_NONNULL = YES; 347 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 348 | CLANG_CXX_LIBRARY = "libc++"; 349 | CLANG_ENABLE_MODULES = YES; 350 | CLANG_ENABLE_OBJC_ARC = YES; 351 | CLANG_WARN_BOOL_CONVERSION = YES; 352 | CLANG_WARN_CONSTANT_CONVERSION = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 360 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 361 | CLANG_WARN_UNREACHABLE_CODE = YES; 362 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 363 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 364 | COPY_PHASE_STRIP = NO; 365 | DEBUG_INFORMATION_FORMAT = dwarf; 366 | ENABLE_STRICT_OBJC_MSGSEND = YES; 367 | ENABLE_TESTABILITY = YES; 368 | GCC_C_LANGUAGE_STANDARD = gnu99; 369 | GCC_DYNAMIC_NO_PIC = NO; 370 | GCC_NO_COMMON_BLOCKS = YES; 371 | GCC_OPTIMIZATION_LEVEL = 0; 372 | GCC_PREPROCESSOR_DEFINITIONS = ( 373 | "DEBUG=1", 374 | "$(inherited)", 375 | ); 376 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 377 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 378 | GCC_WARN_UNDECLARED_SELECTOR = YES; 379 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 380 | GCC_WARN_UNUSED_FUNCTION = YES; 381 | GCC_WARN_UNUSED_VARIABLE = YES; 382 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 383 | MTL_ENABLE_DEBUG_INFO = YES; 384 | ONLY_ACTIVE_ARCH = YES; 385 | SDKROOT = iphoneos; 386 | TARGETED_DEVICE_FAMILY = "1,2"; 387 | }; 388 | name = Debug; 389 | }; 390 | 1A8947891E7AE73E00667E81 /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ALWAYS_SEARCH_USER_PATHS = NO; 394 | CLANG_ANALYZER_NONNULL = YES; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BOOL_CONVERSION = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 408 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 409 | CLANG_WARN_UNREACHABLE_CODE = YES; 410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 411 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 412 | COPY_PHASE_STRIP = NO; 413 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 414 | ENABLE_NS_ASSERTIONS = NO; 415 | ENABLE_STRICT_OBJC_MSGSEND = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu99; 417 | GCC_NO_COMMON_BLOCKS = YES; 418 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 419 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 420 | GCC_WARN_UNDECLARED_SELECTOR = YES; 421 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 422 | GCC_WARN_UNUSED_FUNCTION = YES; 423 | GCC_WARN_UNUSED_VARIABLE = YES; 424 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 425 | MTL_ENABLE_DEBUG_INFO = NO; 426 | SDKROOT = iphoneos; 427 | TARGETED_DEVICE_FAMILY = "1,2"; 428 | VALIDATE_PRODUCT = YES; 429 | }; 430 | name = Release; 431 | }; 432 | 1A89478B1E7AE73E00667E81 /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 436 | DEVELOPMENT_TEAM = 652U6LDTX4; 437 | INFOPLIST_FILE = FloatView/Info.plist; 438 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 439 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatView; 440 | PRODUCT_NAME = "$(TARGET_NAME)"; 441 | }; 442 | name = Debug; 443 | }; 444 | 1A89478C1E7AE73E00667E81 /* Release */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | DEVELOPMENT_TEAM = 652U6LDTX4; 449 | INFOPLIST_FILE = FloatView/Info.plist; 450 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 451 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatView; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | }; 454 | name = Release; 455 | }; 456 | 1A89478E1E7AE73E00667E81 /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | BUNDLE_LOADER = "$(TEST_HOST)"; 460 | DEVELOPMENT_TEAM = 652U6LDTX4; 461 | INFOPLIST_FILE = FloatViewTests/Info.plist; 462 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 463 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatViewTests; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FloatView.app/FloatView"; 466 | }; 467 | name = Debug; 468 | }; 469 | 1A89478F1E7AE73E00667E81 /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | BUNDLE_LOADER = "$(TEST_HOST)"; 473 | DEVELOPMENT_TEAM = 652U6LDTX4; 474 | INFOPLIST_FILE = FloatViewTests/Info.plist; 475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 476 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatViewTests; 477 | PRODUCT_NAME = "$(TARGET_NAME)"; 478 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FloatView.app/FloatView"; 479 | }; 480 | name = Release; 481 | }; 482 | 1A8947911E7AE73E00667E81 /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | DEVELOPMENT_TEAM = 652U6LDTX4; 486 | INFOPLIST_FILE = FloatViewUITests/Info.plist; 487 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 488 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatViewUITests; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | TEST_TARGET_NAME = FloatView; 491 | }; 492 | name = Debug; 493 | }; 494 | 1A8947921E7AE73E00667E81 /* Release */ = { 495 | isa = XCBuildConfiguration; 496 | buildSettings = { 497 | DEVELOPMENT_TEAM = 652U6LDTX4; 498 | INFOPLIST_FILE = FloatViewUITests/Info.plist; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 500 | PRODUCT_BUNDLE_IDENTIFIER = video.wangrui.com.FloatViewUITests; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | TEST_TARGET_NAME = FloatView; 503 | }; 504 | name = Release; 505 | }; 506 | /* End XCBuildConfiguration section */ 507 | 508 | /* Begin XCConfigurationList section */ 509 | 1A8947581E7AE73D00667E81 /* Build configuration list for PBXProject "FloatView" */ = { 510 | isa = XCConfigurationList; 511 | buildConfigurations = ( 512 | 1A8947881E7AE73E00667E81 /* Debug */, 513 | 1A8947891E7AE73E00667E81 /* Release */, 514 | ); 515 | defaultConfigurationIsVisible = 0; 516 | defaultConfigurationName = Release; 517 | }; 518 | 1A89478A1E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatView" */ = { 519 | isa = XCConfigurationList; 520 | buildConfigurations = ( 521 | 1A89478B1E7AE73E00667E81 /* Debug */, 522 | 1A89478C1E7AE73E00667E81 /* Release */, 523 | ); 524 | defaultConfigurationIsVisible = 0; 525 | defaultConfigurationName = Release; 526 | }; 527 | 1A89478D1E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatViewTests" */ = { 528 | isa = XCConfigurationList; 529 | buildConfigurations = ( 530 | 1A89478E1E7AE73E00667E81 /* Debug */, 531 | 1A89478F1E7AE73E00667E81 /* Release */, 532 | ); 533 | defaultConfigurationIsVisible = 0; 534 | defaultConfigurationName = Release; 535 | }; 536 | 1A8947901E7AE73E00667E81 /* Build configuration list for PBXNativeTarget "FloatViewUITests" */ = { 537 | isa = XCConfigurationList; 538 | buildConfigurations = ( 539 | 1A8947911E7AE73E00667E81 /* Debug */, 540 | 1A8947921E7AE73E00667E81 /* Release */, 541 | ); 542 | defaultConfigurationIsVisible = 0; 543 | defaultConfigurationName = Release; 544 | }; 545 | /* End XCConfigurationList section */ 546 | }; 547 | rootObject = 1A8947551E7AE73D00667E81 /* Project object */; 548 | } 549 | -------------------------------------------------------------------------------- /FloatView/FloatView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /FloatView/FloatView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /FloatView/FloatView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /FloatView/FloatView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /FloatView/FloatView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /FloatView/FloatView/Assets.xcassets/FloatBonus.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "FloatBonus@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "FloatBonus@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /FloatView/FloatView/Assets.xcassets/FloatBonus.imageset/FloatBonus@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangrui460/FloatView/cf756d3c87458ba70528bdbc473d2dbaa99683f0/FloatView/FloatView/Assets.xcassets/FloatBonus.imageset/FloatBonus@2x.png -------------------------------------------------------------------------------- /FloatView/FloatView/Assets.xcassets/FloatBonus.imageset/FloatBonus@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangrui460/FloatView/cf756d3c87458ba70528bdbc473d2dbaa99683f0/FloatView/FloatView/Assets.xcassets/FloatBonus.imageset/FloatBonus@3x.png -------------------------------------------------------------------------------- /FloatView/FloatView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /FloatView/FloatView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /FloatView/FloatView/FloatView.h: -------------------------------------------------------------------------------- 1 | // 2 | // FloatView.h 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // 停留方式 12 | typedef NS_ENUM(NSInteger, StayMode) { 13 | // 停靠左右两侧 14 | STAYMODE_LEFTANDRIGHT = 0, 15 | // 停靠左侧 16 | STAYMODE_LEFT = 1, 17 | // 停靠右侧 18 | STAYMODE_RIGHT = 2 19 | }; 20 | 21 | @interface FloatView : UIImageView 22 | 23 | /** 悬浮图片停留的方式(默认为STAYMODE_LEFTANDRIGHT) */ 24 | @property (nonatomic, assign) StayMode stayMode; 25 | 26 | /** 悬浮图片左右边距(默认5)*/ 27 | @property (nonatomic, assign) CGFloat stayEdgeDistance; 28 | 29 | /** 悬浮图片停靠的动画事件(默认0.3秒)*/ 30 | @property (nonatomic, assign) CGFloat stayAnimateTime; 31 | 32 | /** 设置简单的轻点 block事件 */ 33 | - (void)setTapActionWithBlock:(void (^)(void))block; 34 | 35 | /** 根据 imageName 改变FloatView的image */ 36 | - (void)setImageWithName:(NSString *)imageName; 37 | 38 | /** 当滚动的时候悬浮图片居中在屏幕边缘 */ 39 | - (void)moveTohalfInScreenWhenScrolling; 40 | 41 | /** 设置当前浮动图片的透明度 */ 42 | - (void)setCurrentAlpha:(CGFloat)stayAlpha; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /FloatView/FloatView/FloatView.m: -------------------------------------------------------------------------------- 1 | // 2 | // FloatView.m 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import "FloatView.h" 10 | #import 11 | 12 | #define NavBarBottom 64 13 | #define TabBarHeight 49 14 | #define kScreenWidth [UIScreen mainScreen].bounds.size.width 15 | #define kScreenHeight [UIScreen mainScreen].bounds.size.height 16 | 17 | static char kActionHandlerTapBlockKey; 18 | static char kActionHandlerTapGestureKey; 19 | 20 | @implementation FloatView 21 | { 22 | BOOL mIsHalfInScreen; 23 | } 24 | 25 | - (instancetype)initWithImage:(UIImage *)image 26 | { 27 | if (self = [super initWithImage:image]) { 28 | self.userInteractionEnabled = YES; 29 | self.stayEdgeDistance = 5; 30 | self.stayAnimateTime = 0.3; 31 | [self initStayLocation]; 32 | } 33 | return self; 34 | } 35 | 36 | - (instancetype)initWithFrame:(CGRect)frame 37 | { 38 | if (self = [super initWithFrame:frame]) { 39 | self = [[FloatView alloc] initWithImage:[UIImage imageNamed:@"FloatBonus"]]; 40 | self.userInteractionEnabled = YES; 41 | self.stayEdgeDistance = 5; 42 | self.stayAnimateTime = 0.3; 43 | [self initStayLocation]; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 49 | { 50 | // 先让悬浮图片的alpha为1 51 | self.alpha = 1; 52 | // 获取手指当前的点 53 | UITouch * touch = [touches anyObject]; 54 | CGPoint curPoint = [touch locationInView:self]; 55 | 56 | CGPoint prePoint = [touch previousLocationInView:self]; 57 | 58 | // x方向移动的距离 59 | CGFloat deltaX = curPoint.x - prePoint.x; 60 | CGFloat deltaY = curPoint.y - prePoint.y; 61 | CGRect frame = self.frame; 62 | frame.origin.x += deltaX; 63 | frame.origin.y += deltaY; 64 | self.frame = frame; 65 | } 66 | 67 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 68 | { 69 | [self moveStay]; 70 | // 这里可以设置过几秒,alpha减小 71 | // __weak typeof(self) weakSelf = self; 72 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 73 | // [pThis animateHidden]; 74 | }); 75 | } 76 | 77 | #pragma mark - 设置浮动图片的初始位置 78 | - (void)initStayLocation 79 | { 80 | CGRect frame = self.frame; 81 | CGFloat stayWidth = frame.size.width; 82 | CGFloat initX = kScreenWidth - self.stayEdgeDistance - stayWidth; 83 | CGFloat initY = (kScreenHeight - NavBarBottom - TabBarHeight) * (2.0 / 3.0) + NavBarBottom; 84 | frame.origin.x = initX; 85 | frame.origin.y = initY; 86 | self.frame = frame; 87 | mIsHalfInScreen = NO; 88 | } 89 | 90 | #pragma mark - 根据 stayModel 来移动悬浮图片 91 | - (void)moveStay 92 | { 93 | bool isLeft = [self judgeLocationIsLeft]; 94 | switch (_stayMode) { 95 | case STAYMODE_LEFTANDRIGHT: 96 | { 97 | [self moveToBorder:isLeft]; 98 | } 99 | break; 100 | case STAYMODE_LEFT: 101 | { 102 | [self moveToBorder:YES]; 103 | } 104 | break; 105 | case STAYMODE_RIGHT: 106 | { 107 | [self moveToBorder:NO]; 108 | } 109 | break; 110 | default: 111 | break; 112 | } 113 | } 114 | 115 | #pragma mark - 移动到屏幕边缘 116 | - (void)moveToBorder:(BOOL)isLeft 117 | { 118 | CGRect frame = self.frame; 119 | CGFloat destinationX; 120 | if (isLeft) { 121 | destinationX = self.stayEdgeDistance; 122 | } 123 | else { 124 | CGFloat stayWidth = frame.size.width; 125 | destinationX = kScreenWidth - self.stayEdgeDistance - stayWidth; 126 | } 127 | frame.origin.x = destinationX; 128 | frame.origin.y = [self moveSafeLocationY]; 129 | __weak typeof(self) weakSelf = self; 130 | [UIView animateWithDuration:_stayAnimateTime animations:^{ 131 | __strong typeof(self) pThis = weakSelf; 132 | pThis.frame = frame; 133 | }]; 134 | mIsHalfInScreen = NO; 135 | } 136 | 137 | // 设置悬浮图片不高于屏幕顶端,不低于屏幕底端 138 | - (CGFloat)moveSafeLocationY 139 | { 140 | CGRect frame = self.frame; 141 | CGFloat stayHeight = frame.size.height; 142 | // 当前view的y值 143 | CGFloat curY = self.frame.origin.y; 144 | CGFloat destinationY = frame.origin.y; 145 | // 悬浮图片的最顶端Y值 146 | CGFloat stayMostTopY = NavBarBottom + _stayEdgeDistance; 147 | if (curY <= stayMostTopY) { 148 | destinationY = stayMostTopY; 149 | } 150 | // 悬浮图片的底端Y值 151 | CGFloat stayMostBottomY = kScreenHeight - TabBarHeight - _stayEdgeDistance - stayHeight; 152 | if (curY >= stayMostBottomY) { 153 | destinationY = stayMostBottomY; 154 | } 155 | return destinationY; 156 | } 157 | 158 | #pragma mark - 判断当前view是否在父界面的左边 159 | - (bool)judgeLocationIsLeft 160 | { 161 | // 手机屏幕中间位置x值 162 | CGFloat middleX = [UIScreen mainScreen].bounds.size.width / 2.0; 163 | // 当前view的x值 164 | CGFloat curX = self.frame.origin.x + self.bounds.size.width/2; 165 | if (curX <= middleX) { 166 | return YES; 167 | } else { 168 | return NO; 169 | } 170 | } 171 | 172 | #pragma mark - 当滚动的时候悬浮图片居中在屏幕边缘 173 | - (void)moveTohalfInScreenWhenScrolling 174 | { 175 | bool isLeft = [self judgeLocationIsLeft]; 176 | [self moveStayToMiddleInScreenBorder:isLeft]; 177 | mIsHalfInScreen = YES; 178 | } 179 | 180 | // 悬浮图片居中在屏幕边缘 181 | - (void)moveStayToMiddleInScreenBorder:(BOOL)isLeft 182 | { 183 | CGRect frame = self.frame; 184 | CGFloat stayWidth = frame.size.width; 185 | CGFloat destinationX; 186 | if (isLeft == YES) { 187 | destinationX = - stayWidth/2; 188 | } 189 | else { 190 | destinationX = kScreenWidth - stayWidth + stayWidth/2; 191 | } 192 | frame.origin.x = destinationX; 193 | __weak typeof(self) weakSelf = self; 194 | [UIView animateWithDuration:0.2 animations:^{ 195 | __strong typeof(self) pThis = weakSelf; 196 | pThis.frame = frame; 197 | }]; 198 | } 199 | 200 | #pragma mark - 设置当前浮动图片的透明度 201 | - (void)setCurrentAlpha:(CGFloat)stayAlpha 202 | { 203 | if (stayAlpha <= 0) { 204 | stayAlpha = 1; 205 | } 206 | self.alpha = stayAlpha; 207 | } 208 | 209 | #pragma mark - 设置简单的轻点 block事件 210 | - (void)setTapActionWithBlock:(void (^)(void))block 211 | { 212 | // 为gesture添加关联是为了gesture只创建一次,objc_getAssociatedObject如果返回nil就创建一次 213 | UITapGestureRecognizer *gesture = objc_getAssociatedObject(self, &kActionHandlerTapGestureKey); 214 | 215 | if (!gesture) 216 | { 217 | gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleActionForTapGesture:)]; 218 | [self addGestureRecognizer:gesture]; 219 | objc_setAssociatedObject(self, &kActionHandlerTapGestureKey, gesture, OBJC_ASSOCIATION_RETAIN); 220 | } 221 | 222 | objc_setAssociatedObject(self, &kActionHandlerTapBlockKey, block, OBJC_ASSOCIATION_COPY); 223 | } 224 | 225 | - (void)handleActionForTapGesture:(UITapGestureRecognizer *)gesture 226 | { 227 | if (gesture.state == UIGestureRecognizerStateRecognized) 228 | { 229 | void(^action)(void) = objc_getAssociatedObject(self, &kActionHandlerTapBlockKey); 230 | if (action) 231 | { 232 | // 先让悬浮图片的alpha为1 233 | self.alpha = 1; 234 | if (mIsHalfInScreen == NO) { 235 | action(); 236 | } 237 | else { 238 | [self moveStay]; 239 | } 240 | } 241 | } 242 | } 243 | 244 | #pragma mark - getter / setter 245 | - (void)setImageWithName:(NSString *)imageName 246 | { 247 | self.image = [UIImage imageNamed:imageName]; 248 | } 249 | 250 | @end 251 | -------------------------------------------------------------------------------- /FloatView/FloatView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /FloatView/FloatView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /FloatView/FloatView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "FloatView.h" 11 | 12 | @interface ViewController () 13 | @property (nonatomic, strong) UITableView *tableView; 14 | @property (nonatomic, strong) FloatView* floatView; 15 | @end 16 | 17 | @implementation ViewController 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | 23 | [self.view addSubview:self.tableView]; 24 | // self.floatView = [[FloatView alloc] initWithImage:[UIImage imageNamed:@"FloatBonus"]]; 25 | self.floatView = [FloatView new]; 26 | [self.floatView setImageWithName:@"FloatBonus"]; 27 | self.floatView.stayMode = STAYMODE_LEFTANDRIGHT; 28 | [self.floatView setTapActionWithBlock:^{ 29 | NSLog(@"跳转到邀请好友界面"); 30 | }]; 31 | [self.view addSubview:self.floatView]; 32 | // [self.view bringSubviewToFront:self.floatView]; 33 | } 34 | 35 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 36 | { 37 | [self.floatView moveTohalfInScreenWhenScrolling]; 38 | } 39 | 40 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 41 | { 42 | [self.floatView setCurrentAlpha:0.5]; 43 | } 44 | 45 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 46 | { 47 | [self.floatView setCurrentAlpha:1]; 48 | } 49 | 50 | - (UITableView *)tableView 51 | { 52 | if (_tableView == nil) { 53 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain]; 54 | _tableView.delegate = self; 55 | } 56 | return _tableView; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /FloatView/FloatView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FloatView 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /FloatView/FloatViewTests/FloatViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FloatViewTests.m 3 | // FloatViewTests 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FloatViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FloatViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /FloatView/FloatViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /FloatView/FloatViewUITests/FloatViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FloatViewUITests.m 3 | // FloatViewUITests 4 | // 5 | // Created by wangrui on 2017/3/16. 6 | // Copyright © 2017年 wangrui. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FloatViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FloatViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /FloatView/FloatViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 wangrui460 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## iOS 技术交流 2 | 我创建了一个 微信 iOS 技术交流群,欢迎小伙伴们加入一起交流学习~ 3 | 4 | 可以加我微信我拉你进去(备注iOS),我的微信号 wr1204607318 5 | 6 | ## FloatView 7 | 浮动图片 8 | 9 | ![image](https://github.com/wangrui460/FloatView/raw/master/screenshots/FloatView.gif) 10 | 11 | ### 使用方式 12 |

13 | 创建方式一:
14 | FloatView* floatView = [[FloatView alloc] initWithImage:[UIImage imageNamed:@"FloatBonus"]];
15 | 创建方式二:
16 | FloatView* floatView = [FloatView new];
17 | [floatView setImageWithName:@"FloatBonus"];
18 | 
19 | floatView.stayAlpha = 0.3;
20 | floatView.stayMode = STAYMODE_RIGHT;
21 | [floatView setTapActionWithBlock:^{
22 |     NSLog(@"跳转到邀请好友界面");
23 | }];
24 | [self.view addSubview:floatView];
25 | 
26 | 27 | 28 | ### 联系我 29 | 扫码回复1获取面试资料(持续更新) 30 | ![](https://user-images.githubusercontent.com/11909313/123933944-6a4abe00-d9c5-11eb-83ca-379313a2af7c.png) 31 | -------------------------------------------------------------------------------- /screenshots/FloatView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wangrui460/FloatView/cf756d3c87458ba70528bdbc473d2dbaa99683f0/screenshots/FloatView.gif --------------------------------------------------------------------------------