├── Podfile ├── Podfile.lock ├── Pods ├── Headers │ ├── Private │ │ └── Masonry │ │ │ ├── MASCompositeConstraint.h │ │ │ ├── MASConstraint+Private.h │ │ │ ├── MASConstraint.h │ │ │ ├── MASConstraintMaker.h │ │ │ ├── MASLayoutConstraint.h │ │ │ ├── MASUtilities.h │ │ │ ├── MASViewAttribute.h │ │ │ ├── MASViewConstraint.h │ │ │ ├── Masonry.h │ │ │ ├── NSArray+MASAdditions.h │ │ │ ├── NSArray+MASShorthandAdditions.h │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ │ ├── View+MASAdditions.h │ │ │ ├── View+MASShorthandAdditions.h │ │ │ └── ViewController+MASAdditions.h │ └── Public │ │ └── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraintMaker.h │ │ ├── MASLayoutConstraint.h │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewConstraint.h │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── View+MASAdditions.h │ │ ├── View+MASShorthandAdditions.h │ │ └── ViewController+MASAdditions.h ├── Manifest.lock ├── Masonry │ ├── LICENSE │ ├── Masonry │ │ ├── MASCompositeConstraint.h │ │ ├── MASCompositeConstraint.m │ │ ├── MASConstraint+Private.h │ │ ├── MASConstraint.h │ │ ├── MASConstraint.m │ │ ├── MASConstraintMaker.h │ │ ├── MASConstraintMaker.m │ │ ├── MASLayoutConstraint.h │ │ ├── MASLayoutConstraint.m │ │ ├── MASUtilities.h │ │ ├── MASViewAttribute.h │ │ ├── MASViewAttribute.m │ │ ├── MASViewConstraint.h │ │ ├── MASViewConstraint.m │ │ ├── Masonry.h │ │ ├── NSArray+MASAdditions.h │ │ ├── NSArray+MASAdditions.m │ │ ├── NSArray+MASShorthandAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.h │ │ ├── NSLayoutConstraint+MASDebugAdditions.m │ │ ├── View+MASAdditions.h │ │ ├── View+MASAdditions.m │ │ ├── View+MASShorthandAdditions.h │ │ ├── ViewController+MASAdditions.h │ │ └── ViewController+MASAdditions.m │ └── README.md ├── Pods.xcodeproj │ ├── project.pbxproj │ └── xcuserdata │ │ ├── jiangxiao.xcuserdatad │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ │ └── lanaohudong.xcuserdatad │ │ └── xcschemes │ │ ├── Masonry.xcscheme │ │ ├── Pods-douyin.xcscheme │ │ └── xcschememanagement.plist └── Target Support Files │ ├── Masonry │ ├── Masonry-dummy.m │ ├── Masonry-prefix.pch │ └── Masonry.xcconfig │ └── Pods-douyin │ ├── Pods-douyin-acknowledgements.markdown │ ├── Pods-douyin-acknowledgements.plist │ ├── Pods-douyin-dummy.m │ ├── Pods-douyin-frameworks.sh │ ├── Pods-douyin-resources.sh │ ├── Pods-douyin.debug.xcconfig │ └── Pods-douyin.release.xcconfig ├── README.md ├── demo.gif ├── douyin.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ ├── jiangxiao.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── lanaohudong.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── jiangxiao.xcuserdatad │ └── xcschemes │ │ └── xcschememanagement.plist │ └── lanaohudong.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── douyin.xcscheme │ └── xcschememanagement.plist ├── douyin.xcworkspace ├── contents.xcworkspacedata ├── xcshareddata │ └── IDEWorkspaceChecks.plist └── xcuserdata │ ├── jiangxiao.xcuserdatad │ └── UserInterfaceState.xcuserstate │ └── lanaohudong.xcuserdatad │ ├── UserInterfaceState.xcuserstate │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── douyin ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── placeholder1.imageset │ │ ├── Contents.json │ │ ├── placeholder2@2x.png │ │ └── placeholder2@3x.png │ ├── sousuo.imageset │ │ ├── Contents.json │ │ └── sousuo@2x.png │ └── xuexi_yinpin_btn_bofang.imageset │ │ ├── Contents.json │ │ ├── xuexi_yinpin_btn_bofang@2x.png │ │ └── xuexi_yinpin_btn_bofang@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── JXRefresh │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── JXRefreshViewController.h │ ├── JXRefreshViewController.m │ ├── RefreshNavigitionView.h │ ├── RefreshNavigitionView.m │ ├── circle@2x.png │ └── circle@3x.png ├── MJRefresh │ ├── LICENSE │ ├── MJRefresh │ │ ├── Base │ │ │ ├── MJRefreshAutoFooter.h │ │ │ ├── MJRefreshAutoFooter.m │ │ │ ├── MJRefreshBackFooter.h │ │ │ ├── MJRefreshBackFooter.m │ │ │ ├── MJRefreshComponent.h │ │ │ ├── MJRefreshComponent.m │ │ │ ├── MJRefreshFooter.h │ │ │ ├── MJRefreshFooter.m │ │ │ ├── MJRefreshHeader.h │ │ │ └── MJRefreshHeader.m │ │ ├── Custom │ │ │ ├── Footer │ │ │ │ ├── Auto │ │ │ │ │ ├── MJRefreshAutoGifFooter.h │ │ │ │ │ ├── MJRefreshAutoGifFooter.m │ │ │ │ │ ├── MJRefreshAutoNormalFooter.h │ │ │ │ │ ├── MJRefreshAutoNormalFooter.m │ │ │ │ │ ├── MJRefreshAutoStateFooter.h │ │ │ │ │ └── MJRefreshAutoStateFooter.m │ │ │ │ └── Back │ │ │ │ │ ├── MJRefreshBackGifFooter.h │ │ │ │ │ ├── MJRefreshBackGifFooter.m │ │ │ │ │ ├── MJRefreshBackNormalFooter.h │ │ │ │ │ ├── MJRefreshBackNormalFooter.m │ │ │ │ │ ├── MJRefreshBackStateFooter.h │ │ │ │ │ └── MJRefreshBackStateFooter.m │ │ │ └── Header │ │ │ │ ├── MJRefreshGifHeader.h │ │ │ │ ├── MJRefreshGifHeader.m │ │ │ │ ├── MJRefreshNormalHeader.h │ │ │ │ ├── MJRefreshNormalHeader.m │ │ │ │ ├── MJRefreshStateHeader.h │ │ │ │ └── MJRefreshStateHeader.m │ │ ├── MJRefresh.bundle │ │ │ ├── arrow@2x.png │ │ │ ├── en.lproj │ │ │ │ └── Localizable.strings │ │ │ ├── zh-Hans.lproj │ │ │ │ └── Localizable.strings │ │ │ └── zh-Hant.lproj │ │ │ │ └── Localizable.strings │ │ ├── MJRefresh.h │ │ ├── MJRefreshConst.h │ │ ├── MJRefreshConst.m │ │ ├── NSBundle+MJRefresh.h │ │ ├── NSBundle+MJRefresh.m │ │ ├── UIScrollView+MJExtension.h │ │ ├── UIScrollView+MJExtension.m │ │ ├── UIScrollView+MJRefresh.h │ │ ├── UIScrollView+MJRefresh.m │ │ ├── UIView+MJExtension.h │ │ └── UIView+MJExtension.m │ └── README.md ├── PrefixHeader.pch ├── Resource │ └── JPVideoPlayer │ │ ├── JPResourceLoadingRequestTask.h │ │ ├── JPResourceLoadingRequestTask.m │ │ ├── JPVideoPlayer.bundle │ │ ├── jp_videoplayer_blur@2x.png │ │ ├── jp_videoplayer_blur@3x.png │ │ ├── jp_videoplayer_landscape@2x.png │ │ ├── jp_videoplayer_landscape@3x.png │ │ ├── jp_videoplayer_pause@2x.png │ │ ├── jp_videoplayer_pause@3x.png │ │ ├── jp_videoplayer_play@2x.png │ │ ├── jp_videoplayer_play@3x.png │ │ ├── jp_videoplayer_portrait@2x.png │ │ ├── jp_videoplayer_portrait@3x.png │ │ ├── jp_videoplayer_progress_handler_hightlight@2x.png │ │ ├── jp_videoplayer_progress_handler_hightlight@3x.png │ │ ├── jp_videoplayer_progress_handler_normal@2x.png │ │ └── jp_videoplayer_progress_handler_normal@3x.png │ │ ├── JPVideoPlayer.h │ │ ├── JPVideoPlayer.m │ │ ├── JPVideoPlayerCache.h │ │ ├── JPVideoPlayerCache.m │ │ ├── JPVideoPlayerCacheFile.h │ │ ├── JPVideoPlayerCacheFile.m │ │ ├── JPVideoPlayerCachePath.h │ │ ├── JPVideoPlayerCachePath.m │ │ ├── JPVideoPlayerCompat.h │ │ ├── JPVideoPlayerCompat.m │ │ ├── JPVideoPlayerControlViews.h │ │ ├── JPVideoPlayerControlViews.m │ │ ├── JPVideoPlayerDownloader.h │ │ ├── JPVideoPlayerDownloader.m │ │ ├── JPVideoPlayerManager.h │ │ ├── JPVideoPlayerManager.m │ │ ├── JPVideoPlayerProtocol.h │ │ ├── JPVideoPlayerResourceLoader.h │ │ ├── JPVideoPlayerResourceLoader.m │ │ ├── JPVideoPlayerSupportUtils.h │ │ ├── JPVideoPlayerSupportUtils.m │ │ ├── UITableView+WebVideoCache.h │ │ ├── UITableView+WebVideoCache.m │ │ ├── UITableViewCell+WebVideoCache.h │ │ ├── UITableViewCell+WebVideoCache.m │ │ ├── UIView+WebVideoCache.h │ │ └── UIView+WebVideoCache.m ├── Tools │ ├── JXTableView.h │ ├── JXTableView.m │ ├── JXUIKit.h │ └── JXUIKit.m ├── View │ ├── MainViewNavigitionView.h │ ├── MainViewNavigitionView.m │ ├── VideoTableViewCell.h │ └── VideoTableViewCell.m ├── ViewController.h ├── ViewController.m ├── main.m └── 视频 │ ├── 发布视频 │ ├── PublishVideoViewController.h │ ├── PublishVideoViewController.m │ └── views │ │ ├── JXCustomTextView.h │ │ ├── JXCustomTextView.m │ │ ├── VideoView.h │ │ └── VideoView.m │ └── 选封面 │ ├── ChoseCoverViewController.h │ ├── ChoseCoverViewController.m │ ├── CoverImageCollectionViewCell.h │ └── CoverImageCollectionViewCell.m ├── douyinTests ├── Info.plist └── douyinTests.m ├── douyinUITests ├── Info.plist └── douyinUITests.m ├── erweima.png ├── footeRefresh.gif ├── img1.jpeg └── jiawo.jpg /Podfile: -------------------------------------------------------------------------------- 1 | platform:ios, ‘8.0’ 2 | 3 | target ‘douyin’ do 4 | pod 'Masonry' 5 | end 6 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | 4 | DEPENDENCIES: 5 | - Masonry 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 9 | 10 | PODFILE CHECKSUM: 4325a389ec3f63a9245ddb072e9188b12588cc01 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Private/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASCompositeConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint+Private.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASConstraintMaker.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASLayoutConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASUtilities.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewAttribute.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/MASViewConstraint.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/Masonry.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSArray+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/View+MASShorthandAdditions.h -------------------------------------------------------------------------------- /Pods/Headers/Public/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | ../../../Masonry/Masonry/ViewController+MASAdditions.h -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Masonry (1.1.0) 3 | 4 | DEPENDENCIES: 5 | - Masonry 6 | 7 | SPEC CHECKSUMS: 8 | Masonry: 678fab65091a9290e40e2832a55e7ab731aad201 9 | 10 | PODFILE CHECKSUM: 4325a389ec3f63a9245ddb072e9188b12588cc01 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /Pods/Masonry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASViewConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | typedef NS_ENUM(NSUInteger, MASAxisType) { 14 | MASAxisTypeHorizontal, 15 | MASAxisTypeVertical 16 | }; 17 | 18 | @interface NSArray (MASAdditions) 19 | 20 | /** 21 | * Creates a MASConstraintMaker with each view in the callee. 22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 23 | * 24 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 25 | * 26 | * @return Array of created MASConstraints 27 | */ 28 | - (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 29 | 30 | /** 31 | * Creates a MASConstraintMaker with each view in the callee. 32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 33 | * If an existing constraint exists then it will be updated instead. 34 | * 35 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 36 | * 37 | * @return Array of created/updated MASConstraints 38 | */ 39 | - (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 40 | 41 | /** 42 | * Creates a MASConstraintMaker with each view in the callee. 43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 44 | * All constraints previously installed for the views will be removed. 45 | * 46 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 47 | * 48 | * @return Array of created/updated MASConstraints 49 | */ 50 | - (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block; 51 | 52 | /** 53 | * distribute with fixed spacing 54 | * 55 | * @param axisType which axis to distribute items along 56 | * @param fixedSpacing the spacing between each item 57 | * @param leadSpacing the spacing before the first item and the container 58 | * @param tailSpacing the spacing after the last item and the container 59 | */ 60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 61 | 62 | /** 63 | * distribute with fixed item size 64 | * 65 | * @param axisType which axis to distribute items along 66 | * @param fixedItemLength the fixed length of each item 67 | * @param leadSpacing the spacing before the first item and the container 68 | * @param tailSpacing the spacing after the last item and the container 69 | */ 70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline; 39 | 40 | #endif 41 | 42 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) 43 | 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 52 | 53 | #endif 54 | 55 | #if (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000) || (__TV_OS_VERSION_MAX_ALLOWED >= 110000) 56 | 57 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide API_AVAILABLE(ios(11.0),tvos(11.0)); 58 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop API_AVAILABLE(ios(11.0),tvos(11.0)); 59 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom API_AVAILABLE(ios(11.0),tvos(11.0)); 60 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft API_AVAILABLE(ios(11.0),tvos(11.0)); 61 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight API_AVAILABLE(ios(11.0),tvos(11.0)); 62 | 63 | #endif 64 | 65 | /** 66 | * a key to associate with this view 67 | */ 68 | @property (nonatomic, strong) id mas_key; 69 | 70 | /** 71 | * Finds the closest common superview between this view and another view 72 | * 73 | * @param view other view 74 | * 75 | * @return returns nil if common superview could not be found 76 | */ 77 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 78 | 79 | /** 80 | * Creates a MASConstraintMaker with the callee view. 81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 82 | * 83 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 84 | * 85 | * @return Array of created MASConstraints 86 | */ 87 | - (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 88 | 89 | /** 90 | * Creates a MASConstraintMaker with the callee view. 91 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 92 | * If an existing constraint exists then it will be updated instead. 93 | * 94 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 95 | * 96 | * @return Array of created/updated MASConstraints 97 | */ 98 | - (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 99 | 100 | /** 101 | * Creates a MASConstraintMaker with the callee view. 102 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 103 | * All constraints previously installed for the view will be removed. 104 | * 105 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 106 | * 107 | * @return Array of created/updated MASConstraints 108 | */ 109 | - (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block; 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom; 26 | 27 | 28 | @end 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Pods/Masonry/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | - (MASViewAttribute *)mas_topLayoutGuideTop { 19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 20 | } 21 | - (MASViewAttribute *)mas_topLayoutGuideBottom { 22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 23 | } 24 | 25 | - (MASViewAttribute *)mas_bottomLayoutGuide { 26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 27 | } 28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop { 29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 30 | } 31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom { 32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 33 | } 34 | 35 | 36 | 37 | @end 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/jiangxiao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | Pods-douyin.xcscheme 13 | 14 | orderHint 15 | 2 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcschemes/Masonry.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcschemes/Pods-douyin.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 44 | 45 | 46 | 52 | 53 | 55 | 56 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Pods/Pods.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Masonry.xcscheme 8 | 9 | isShown 10 | 11 | orderHint 12 | 0 13 | 14 | Pods-douyin.xcscheme 15 | 16 | isShown 17 | 18 | orderHint 19 | 1 20 | 21 | 22 | SuppressBuildableAutocreation 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Masonry : NSObject 3 | @end 4 | @implementation PodsDummy_Masonry 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Masonry/Masonry.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Masonry 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Masonry" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 4 | OTHER_LDFLAGS = -framework "Foundation" -framework "UIKit" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Masonry 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Masonry 5 | 6 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | Generated by CocoaPods - https://cocoapods.org 26 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2011-2012 Masonry Team - https://github.com/Masonry 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | License 37 | MIT 38 | Title 39 | Masonry 40 | Type 41 | PSGroupSpecifier 42 | 43 | 44 | FooterText 45 | Generated by CocoaPods - https://cocoapods.org 46 | Title 47 | 48 | Type 49 | PSGroupSpecifier 50 | 51 | 52 | StringsTable 53 | Acknowledgements 54 | Title 55 | Acknowledgements 56 | 57 | 58 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_douyin : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_douyin 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | # This protects against multiple targets copying the same framework dependency at the same time. The solution 10 | # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html 11 | RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") 12 | 13 | install_framework() 14 | { 15 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 16 | local source="${BUILT_PRODUCTS_DIR}/$1" 17 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 18 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 19 | elif [ -r "$1" ]; then 20 | local source="$1" 21 | fi 22 | 23 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | 25 | if [ -L "${source}" ]; then 26 | echo "Symlinked..." 27 | source="$(readlink "${source}")" 28 | fi 29 | 30 | # Use filter instead of exclude so missing patterns don't throw errors. 31 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 32 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 33 | 34 | local basename 35 | basename="$(basename -s .framework "$1")" 36 | binary="${destination}/${basename}.framework/${basename}" 37 | if ! [ -r "$binary" ]; then 38 | binary="${destination}/${basename}" 39 | fi 40 | 41 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 42 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 43 | strip_invalid_archs "$binary" 44 | fi 45 | 46 | # Resign the code if required by the build settings to avoid unstable apps 47 | code_sign_if_enabled "${destination}/$(basename "$1")" 48 | 49 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 50 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 51 | local swift_runtime_libs 52 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 53 | for lib in $swift_runtime_libs; do 54 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 55 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 56 | code_sign_if_enabled "${destination}/${lib}" 57 | done 58 | fi 59 | } 60 | 61 | # Copies the dSYM of a vendored framework 62 | install_dsym() { 63 | local source="$1" 64 | if [ -r "$source" ]; then 65 | echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DWARF_DSYM_FOLDER_PATH}\"" 66 | rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DWARF_DSYM_FOLDER_PATH}" 67 | fi 68 | } 69 | 70 | # Signs a framework with the provided identity 71 | code_sign_if_enabled() { 72 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 73 | # Use the current code_sign_identitiy 74 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 75 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 76 | 77 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 78 | code_sign_cmd="$code_sign_cmd &" 79 | fi 80 | echo "$code_sign_cmd" 81 | eval "$code_sign_cmd" 82 | fi 83 | } 84 | 85 | # Strip invalid architectures 86 | strip_invalid_archs() { 87 | binary="$1" 88 | # Get architectures for current file 89 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 90 | stripped="" 91 | for arch in $archs; do 92 | if ! [[ "${ARCHS}" == *"$arch"* ]]; then 93 | # Strip non-valid architectures in-place 94 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 95 | stripped="$stripped $arch" 96 | fi 97 | done 98 | if [[ "$stripped" ]]; then 99 | echo "Stripped $binary of architectures:$stripped" 100 | fi 101 | } 102 | 103 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 104 | wait 105 | fi 106 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-douyin/Pods-douyin.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Masonry" 3 | LIBRARY_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Masonry" 4 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/Masonry" 5 | OTHER_LDFLAGS = $(inherited) -ObjC -l"Masonry" -framework "Foundation" -framework "UIKit" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 9 | PODS_ROOT = ${SRCROOT}/Pods 10 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/demo.gif -------------------------------------------------------------------------------- /douyin.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /douyin.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /douyin.xcodeproj/project.xcworkspace/xcuserdata/jiangxiao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin.xcodeproj/project.xcworkspace/xcuserdata/jiangxiao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /douyin.xcodeproj/project.xcworkspace/xcuserdata/lanaohudong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin.xcodeproj/project.xcworkspace/xcuserdata/lanaohudong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /douyin.xcodeproj/xcuserdata/jiangxiao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | douyin.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /douyin.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /douyin.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcschemes/douyin.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 44 | 50 | 51 | 52 | 53 | 54 | 60 | 61 | 62 | 63 | 64 | 65 | 76 | 78 | 84 | 85 | 86 | 87 | 88 | 89 | 95 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /douyin.xcodeproj/xcuserdata/lanaohudong.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | douyin.xcscheme 8 | 9 | orderHint 10 | 2 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 7B54BA52207EF23700370B91 16 | 17 | primary 18 | 19 | 20 | 7B54BA6A207EF23700370B91 21 | 22 | primary 23 | 24 | 25 | 7B54BA75207EF23700370B91 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /douyin.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /douyin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /douyin.xcworkspace/xcuserdata/jiangxiao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin.xcworkspace/xcuserdata/jiangxiao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /douyin.xcworkspace/xcuserdata/lanaohudong.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin.xcworkspace/xcuserdata/lanaohudong.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /douyin.xcworkspace/xcuserdata/lanaohudong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 30 | 31 | 32 | 34 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /douyin/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. 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 | -------------------------------------------------------------------------------- /douyin/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "ViewController.h" 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 | 21 | UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:[ViewController new]]; 22 | 23 | self.window.rootViewController = navigation; 24 | self.window.backgroundColor = [UIColor whiteColor]; 25 | [self.window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | 30 | - (void)applicationWillResignActive:(UIApplication *)application { 31 | // 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. 32 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 33 | } 34 | 35 | 36 | - (void)applicationDidEnterBackground:(UIApplication *)application { 37 | // 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. 38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 39 | } 40 | 41 | 42 | - (void)applicationWillEnterForeground:(UIApplication *)application { 43 | // 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. 44 | } 45 | 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // 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. 49 | } 50 | 51 | 52 | - (void)applicationWillTerminate:(UIApplication *)application { 53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 54 | } 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /douyin/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /douyin/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /douyin/Assets.xcassets/placeholder1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "placeholder2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "placeholder2@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /douyin/Assets.xcassets/placeholder1.imageset/placeholder2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Assets.xcassets/placeholder1.imageset/placeholder2@2x.png -------------------------------------------------------------------------------- /douyin/Assets.xcassets/placeholder1.imageset/placeholder2@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Assets.xcassets/placeholder1.imageset/placeholder2@3x.png -------------------------------------------------------------------------------- /douyin/Assets.xcassets/sousuo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "sousuo@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /douyin/Assets.xcassets/sousuo.imageset/sousuo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Assets.xcassets/sousuo.imageset/sousuo@2x.png -------------------------------------------------------------------------------- /douyin/Assets.xcassets/xuexi_yinpin_btn_bofang.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "xuexi_yinpin_btn_bofang@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "xuexi_yinpin_btn_bofang@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /douyin/Assets.xcassets/xuexi_yinpin_btn_bofang.imageset/xuexi_yinpin_btn_bofang@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Assets.xcassets/xuexi_yinpin_btn_bofang.imageset/xuexi_yinpin_btn_bofang@2x.png -------------------------------------------------------------------------------- /douyin/Assets.xcassets/xuexi_yinpin_btn_bofang.imageset/xuexi_yinpin_btn_bofang@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Assets.xcassets/xuexi_yinpin_btn_bofang.imageset/xuexi_yinpin_btn_bofang@3x.png -------------------------------------------------------------------------------- /douyin/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 | -------------------------------------------------------------------------------- /douyin/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 | -------------------------------------------------------------------------------- /douyin/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | zh_CN 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 | NSAppTransportSecurity 24 | 25 | NSAllowsArbitraryLoads 26 | 27 | 28 | NSAppleMusicUsageDescription 29 | 是否允许此App使用您的媒体库? 30 | NSCameraUsageDescription 31 | 获取相机权限 32 | NSMicrophoneUsageDescription 33 | 获取麦克风权限 34 | NSPhotoLibraryAddUsageDescription 35 | 是否允许此APP保存图片? 36 | NSPhotoLibraryUsageDescription 37 | 是否允许此App访问您的相册? 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIMainStoryboardFile 41 | Main 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | 50 | UISupportedInterfaceOrientations~ipad 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationPortraitUpsideDown 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /douyin/JXRefresh/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/JXRefresh/1.png -------------------------------------------------------------------------------- /douyin/JXRefresh/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/JXRefresh/2.png -------------------------------------------------------------------------------- /douyin/JXRefresh/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/JXRefresh/3.png -------------------------------------------------------------------------------- /douyin/JXRefresh/JXRefreshViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JXRefreshViewController.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/13. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef NS_ENUM(NSInteger,StatusOfRefresh) { 11 | REFRESH_Normal = 0, //正常状态 12 | REFRESH_MoveDown , //手指下拉 13 | REFRESH_MoveUp, //手指上拉 14 | XDREFRESH_BeginRefresh, //刷新状态 15 | }; 16 | #define MaxDistance 60 //向下拖拽最大点-刷新临界值 17 | #define MaxScroll 200 //向上拖拽最大点-到达最大点就动画让tableview滚动到第二个cell 18 | @interface JXRefreshViewController : UIViewController 19 | //记录手指滑动状态 20 | @property (nonatomic, assign)StatusOfRefresh refreshStatus; 21 | 22 | @property (nonatomic, copy)void(^refreshBlock)(void); 23 | 24 | /** 25 | 下拉刷新 26 | 27 | @param scrollView 需要添加刷新的tableview或者collectionview 28 | @param navView 需要跟刷新视图切换的上导航 29 | @param block 刷新回调 30 | */ 31 | -(void)addJXRefreshWithTableView:(UIScrollView *)scrollView andNavView:(UIView *)navView andRefreshBlock:(void (^)(void))block; 32 | -(void)endRefresh; 33 | -(void)tapView; 34 | @end 35 | -------------------------------------------------------------------------------- /douyin/JXRefresh/RefreshNavigitionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // RefreshNavigitionView.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RefreshNavigitionView : UIView 12 | @property(nonatomic, strong)UIImageView *circleImage; 13 | -(void)startAnimation; 14 | @end 15 | -------------------------------------------------------------------------------- /douyin/JXRefresh/RefreshNavigitionView.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // RefreshNavigitionView.m 4 | // douyin 5 | // 6 | // Created by 澜海利奥 on 2018/4/12. 7 | // Copyright © 2018年 江萧. All rights reserved. 8 | // 9 | 10 | #import "RefreshNavigitionView.h" 11 | @implementation RefreshNavigitionView 12 | -(instancetype)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if (self) { 16 | UILabel *title = [JXUIKit labelWithBackgroundColor:[UIColor clearColor] textColor:[UIColor whiteColor] textAlignment:NSTextAlignmentCenter numberOfLines:0 fontSize:16 font:nil text:@"下拉刷新内容"]; 17 | [self addSubview:title]; 18 | 19 | MJWeakSelf 20 | [title mas_makeConstraints:^(MASConstraintMaker *make) { 21 | make.centerX.equalTo(weakSelf); 22 | make.bottom.equalTo(weakSelf); 23 | make.width.equalTo(@100); 24 | make.height.equalTo(@(44)); 25 | }]; 26 | 27 | 28 | _circleImage = [JXUIKit imageViewWithBackgroundColor:nil userInteractionEnabled:NO imageName:@"circle"]; 29 | [self addSubview:_circleImage]; 30 | //用masory和frame都可以实现transform动画,sd不行 31 | [_circleImage mas_remakeConstraints:^(MASConstraintMaker *make) { 32 | make.width.equalTo(@18); 33 | make.height.equalTo(@18); 34 | make.bottom.equalTo(self).offset(-13); 35 | make.right.equalTo(self).offset(-20); 36 | }]; 37 | //_circleImage.frame = CGRectMake(kWidth-50, kNavHeight-13-18, 18, 18); 38 | 39 | // _circleImage.sd_layout.rightSpaceToView(self, 20).widthIs(30).heightIs(30).topSpaceToView(self, 27); 40 | // [_circleImage updateLayout]; 41 | } 42 | return self; 43 | } 44 | -(void)startAnimation 45 | { 46 | //要先将transform复位-因为CABasicAnimation动画执行完毕后会自动复位,就是没有执行transform之前的位置,跟transform之后的位置有角度差,会造成视觉上旋转不流畅 47 | self.circleImage.transform = CGAffineTransformIdentity; 48 | CABasicAnimation* rotationAnimation; 49 | rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; 50 | rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0]; 51 | rotationAnimation.duration = 0.5; 52 | rotationAnimation.cumulative = YES; 53 | //重复旋转的次数,如果你想要无数次,那么设置成MAXFLOAT 54 | rotationAnimation.repeatCount = MAXFLOAT; 55 | [self.circleImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; 56 | } 57 | /* 58 | // Only override drawRect: if you perform custom drawing. 59 | // An empty implementation adversely affects performance during animation. 60 | - (void)drawRect:(CGRect)rect { 61 | // Drawing code 62 | } 63 | */ 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /douyin/JXRefresh/circle@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/JXRefresh/circle@2x.png -------------------------------------------------------------------------------- /douyin/JXRefresh/circle@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/JXRefresh/circle@3x.png -------------------------------------------------------------------------------- /douyin/MJRefresh/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshAutoFooter : MJRefreshFooter 12 | /** 是否自动刷新(默认为YES) */ 13 | @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; 14 | 15 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 16 | @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("请使用triggerAutomaticallyRefreshPercent属性"); 17 | 18 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 19 | @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; 20 | @end 21 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoFooter() 12 | @end 13 | 14 | @implementation MJRefreshAutoFooter 15 | 16 | #pragma mark - 初始化 17 | - (void)willMoveToSuperview:(UIView *)newSuperview 18 | { 19 | [super willMoveToSuperview:newSuperview]; 20 | 21 | if (newSuperview) { // 新的父控件 22 | if (self.hidden == NO) { 23 | self.scrollView.mj_insetB += self.mj_h; 24 | } 25 | 26 | // 设置位置 27 | self.mj_y = _scrollView.mj_contentH; 28 | } else { // 被移除了 29 | if (self.hidden == NO) { 30 | self.scrollView.mj_insetB -= self.mj_h; 31 | } 32 | } 33 | } 34 | 35 | #pragma mark - 过期方法 36 | - (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh 37 | { 38 | self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; 39 | } 40 | 41 | - (CGFloat)appearencePercentTriggerAutoRefresh 42 | { 43 | return self.triggerAutomaticallyRefreshPercent; 44 | } 45 | 46 | #pragma mark - 实现父类的方法 47 | - (void)prepare 48 | { 49 | [super prepare]; 50 | 51 | // 默认底部控件100%出现时才会自动刷新 52 | self.triggerAutomaticallyRefreshPercent = 1.0; 53 | 54 | // 设置为默认状态 55 | self.automaticallyRefresh = YES; 56 | } 57 | 58 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change 59 | { 60 | [super scrollViewContentSizeDidChange:change]; 61 | 62 | // 设置位置 63 | self.mj_y = self.scrollView.mj_contentH; 64 | } 65 | 66 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 67 | { 68 | [super scrollViewContentOffsetDidChange:change]; 69 | 70 | if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; 71 | 72 | if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // 内容超过一个屏幕 73 | // 这里的_scrollView.mj_contentH替换掉self.mj_y更为合理 74 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { 75 | // 防止手松开时连续调用 76 | CGPoint old = [change[@"old"] CGPointValue]; 77 | CGPoint new = [change[@"new"] CGPointValue]; 78 | if (new.y <= old.y) return; 79 | 80 | // 当底部刷新控件完全出现时,才刷新 81 | [self beginRefreshing]; 82 | } 83 | } 84 | } 85 | 86 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change 87 | { 88 | [super scrollViewPanStateDidChange:change]; 89 | 90 | if (self.state != MJRefreshStateIdle) return; 91 | 92 | if (_scrollView.panGestureRecognizer.state == UIGestureRecognizerStateEnded) {// 手松开 93 | if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // 不够一个屏幕 94 | if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // 向上拽 95 | [self beginRefreshing]; 96 | } 97 | } else { // 超出一个屏幕 98 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { 99 | [self beginRefreshing]; 100 | } 101 | } 102 | } 103 | } 104 | 105 | - (void)setState:(MJRefreshState)state 106 | { 107 | MJRefreshCheckState 108 | 109 | if (state == MJRefreshStateRefreshing) { 110 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 111 | [self executeRefreshingCallback]; 112 | }); 113 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 114 | if (MJRefreshStateRefreshing == oldState) { 115 | if (self.endRefreshingCompletionBlock) { 116 | self.endRefreshingCompletionBlock(); 117 | } 118 | } 119 | } 120 | } 121 | 122 | - (void)setHidden:(BOOL)hidden 123 | { 124 | BOOL lastHidden = self.isHidden; 125 | 126 | [super setHidden:hidden]; 127 | 128 | if (!lastHidden && hidden) { 129 | self.state = MJRefreshStateIdle; 130 | 131 | self.scrollView.mj_insetB -= self.mj_h; 132 | } else if (lastHidden && !hidden) { 133 | self.scrollView.mj_insetB += self.mj_h; 134 | 135 | // 设置位置 136 | self.mj_y = _scrollView.mj_contentH; 137 | } 138 | } 139 | @end 140 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshBackFooter : MJRefreshFooter 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshComponent.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 刷新控件的基类 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | #import "UIView+MJExtension.h" 13 | #import "UIScrollView+MJExtension.h" 14 | #import "UIScrollView+MJRefresh.h" 15 | #import "NSBundle+MJRefresh.h" 16 | 17 | /** 刷新控件的状态 */ 18 | typedef NS_ENUM(NSInteger, MJRefreshState) { 19 | /** 普通闲置状态 */ 20 | MJRefreshStateIdle = 1, 21 | /** 松开就可以进行刷新的状态 */ 22 | MJRefreshStatePulling, 23 | /** 正在刷新中的状态 */ 24 | MJRefreshStateRefreshing, 25 | /** 即将刷新的状态 */ 26 | MJRefreshStateWillRefresh, 27 | /** 所有数据加载完毕,没有更多的数据了 */ 28 | MJRefreshStateNoMoreData 29 | }; 30 | 31 | /** 进入刷新状态的回调 */ 32 | typedef void (^MJRefreshComponentRefreshingBlock)(void); 33 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 34 | typedef void (^MJRefreshComponentbeginRefreshingCompletionBlock)(void); 35 | /** 结束刷新后的回调 */ 36 | typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(void); 37 | 38 | /** 刷新控件的基类 */ 39 | @interface MJRefreshComponent : UIView 40 | { 41 | /** 记录scrollView刚开始的inset */ 42 | UIEdgeInsets _scrollViewOriginalInset; 43 | /** 父控件 */ 44 | __weak UIScrollView *_scrollView; 45 | } 46 | #pragma mark - 刷新回调 47 | /** 正在刷新的回调 */ 48 | @property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; 49 | /** 设置回调对象和回调方法 */ 50 | - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; 51 | 52 | /** 回调对象 */ 53 | @property (weak, nonatomic) id refreshingTarget; 54 | /** 回调方法 */ 55 | @property (assign, nonatomic) SEL refreshingAction; 56 | /** 触发回调(交给子类去调用) */ 57 | - (void)executeRefreshingCallback; 58 | 59 | #pragma mark - 刷新状态控制 60 | /** 进入刷新状态 */ 61 | - (void)beginRefreshing; 62 | - (void)beginRefreshingWithCompletionBlock:(void (^)(void))completionBlock; 63 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 64 | @property (copy, nonatomic) MJRefreshComponentbeginRefreshingCompletionBlock beginRefreshingCompletionBlock; 65 | /** 结束刷新的回调 */ 66 | @property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock; 67 | /** 结束刷新状态 */ 68 | - (void)endRefreshing; 69 | - (void)endRefreshingWithCompletionBlock:(void (^)(void))completionBlock; 70 | /** 是否正在刷新 */ 71 | @property (assign, nonatomic, readonly, getter=isRefreshing) BOOL refreshing; 72 | //- (BOOL)isRefreshing; 73 | /** 刷新状态 一般交给子类内部实现 */ 74 | @property (assign, nonatomic) MJRefreshState state; 75 | 76 | #pragma mark - 交给子类去访问 77 | /** 记录scrollView刚开始的inset */ 78 | @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; 79 | /** 父控件 */ 80 | @property (weak, nonatomic, readonly) UIScrollView *scrollView; 81 | 82 | #pragma mark - 交给子类们去实现 83 | /** 初始化 */ 84 | - (void)prepare NS_REQUIRES_SUPER; 85 | /** 摆放子控件frame */ 86 | - (void)placeSubviews NS_REQUIRES_SUPER; 87 | /** 当scrollView的contentOffset发生改变的时候调用 */ 88 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 89 | /** 当scrollView的contentSize发生改变的时候调用 */ 90 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 91 | /** 当scrollView的拖拽状态发生改变的时候调用 */ 92 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 93 | 94 | 95 | #pragma mark - 其他 96 | /** 拉拽的百分比(交给子类重写) */ 97 | @property (assign, nonatomic) CGFloat pullingPercent; 98 | /** 根据拖拽比例自动切换透明度 */ 99 | @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); 100 | /** 根据拖拽比例自动切换透明度 */ 101 | @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; 102 | @end 103 | 104 | @interface UILabel(MJRefresh) 105 | + (instancetype)mj_label; 106 | - (CGFloat)mj_textWith; 107 | @end 108 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 上拉刷新控件 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshFooter : MJRefreshComponent 13 | /** 创建footer */ 14 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建footer */ 16 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 提示没有更多的数据 */ 19 | - (void)endRefreshingWithNoMoreData; 20 | - (void)noticeNoMoreData MJRefreshDeprecated("使用endRefreshingWithNoMoreData"); 21 | 22 | /** 重置没有更多的数据(消除没有更多数据的状态) */ 23 | - (void)resetNoMoreData; 24 | 25 | /** 忽略多少scrollView的contentInset的bottom */ 26 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; 27 | 28 | /** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏。默认是NO) */ 29 | @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; 30 | @end 31 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshFooter.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshFooter.h" 11 | 12 | @interface MJRefreshFooter() 13 | 14 | @end 15 | 16 | @implementation MJRefreshFooter 17 | #pragma mark - 构造方法 18 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshFooter *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshFooter *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 重写父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置自己的高度 37 | self.mj_h = MJRefreshFooterHeight; 38 | 39 | // 默认不会自动隐藏 40 | self.automaticallyHidden = NO; 41 | } 42 | 43 | - (void)willMoveToSuperview:(UIView *)newSuperview 44 | { 45 | [super willMoveToSuperview:newSuperview]; 46 | 47 | if (newSuperview) { 48 | // 监听scrollView数据的变化 49 | if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { 50 | [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { 51 | if (self.isAutomaticallyHidden) { 52 | self.hidden = (totalDataCount == 0); 53 | } 54 | }]; 55 | } 56 | } 57 | } 58 | 59 | #pragma mark - 公共方法 60 | - (void)endRefreshingWithNoMoreData 61 | { 62 | dispatch_async(dispatch_get_main_queue(), ^{ 63 | self.state = MJRefreshStateNoMoreData; 64 | }); 65 | } 66 | 67 | - (void)noticeNoMoreData 68 | { 69 | [self endRefreshingWithNoMoreData]; 70 | } 71 | 72 | - (void)resetNoMoreData 73 | { 74 | dispatch_async(dispatch_get_main_queue(), ^{ 75 | self.state = MJRefreshStateIdle; 76 | }); 77 | } 78 | @end 79 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Base/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 下拉刷新控件:负责监控用户下拉的状态 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshHeader : MJRefreshComponent 13 | /** 创建header */ 14 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建header */ 16 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 这个key用来存储上一次下拉刷新成功的时间 */ 19 | @property (copy, nonatomic) NSString *lastUpdatedTimeKey; 20 | /** 上一次下拉刷新成功的时间 */ 21 | @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; 22 | 23 | /** 忽略多少scrollView的contentInset的top */ 24 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; 25 | @end 26 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoGifFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshAutoGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)placeSubviews 78 | { 79 | [super placeSubviews]; 80 | 81 | if (self.gifView.constraints.count) return; 82 | 83 | self.gifView.frame = self.bounds; 84 | if (self.isRefreshingTitleHidden) { 85 | self.gifView.contentMode = UIViewContentModeCenter; 86 | } else { 87 | self.gifView.contentMode = UIViewContentModeRight; 88 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 89 | } 90 | } 91 | 92 | - (void)setState:(MJRefreshState)state 93 | { 94 | MJRefreshCheckState 95 | 96 | // 根据状态做事情 97 | if (state == MJRefreshStateRefreshing) { 98 | NSArray *images = self.stateImages[@(state)]; 99 | if (images.count == 0) return; 100 | [self.gifView stopAnimating]; 101 | 102 | self.gifView.hidden = NO; 103 | if (images.count == 1) { // 单张图片 104 | self.gifView.image = [images lastObject]; 105 | } else { // 多张图片 106 | self.gifView.animationImages = images; 107 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 108 | [self.gifView startAnimating]; 109 | } 110 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 111 | [self.gifView stopAnimating]; 112 | self.gifView.hidden = YES; 113 | } 114 | } 115 | @end 116 | 117 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter 12 | /** 菊花的样式 */ 13 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 14 | @end 15 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoNormalFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter() 12 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 13 | @end 14 | 15 | @implementation MJRefreshAutoNormalFooter 16 | #pragma mark - 懒加载子控件 17 | - (UIActivityIndicatorView *)loadingView 18 | { 19 | if (!_loadingView) { 20 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 21 | loadingView.hidesWhenStopped = YES; 22 | [self addSubview:_loadingView = loadingView]; 23 | } 24 | return _loadingView; 25 | } 26 | 27 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 28 | { 29 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 30 | 31 | self.loadingView = nil; 32 | [self setNeedsLayout]; 33 | } 34 | #pragma mark - 重写父类的方法 35 | - (void)prepare 36 | { 37 | [super prepare]; 38 | 39 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 40 | } 41 | 42 | - (void)placeSubviews 43 | { 44 | [super placeSubviews]; 45 | 46 | if (self.loadingView.constraints.count) return; 47 | 48 | // 圈圈 49 | CGFloat loadingCenterX = self.mj_w * 0.5; 50 | if (!self.isRefreshingTitleHidden) { 51 | loadingCenterX -= self.stateLabel.mj_textWith * 0.5 + self.labelLeftInset; 52 | } 53 | CGFloat loadingCenterY = self.mj_h * 0.5; 54 | self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); 55 | } 56 | 57 | - (void)setState:(MJRefreshState)state 58 | { 59 | MJRefreshCheckState 60 | 61 | // 根据状态做事情 62 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 63 | [self.loadingView stopAnimating]; 64 | } else if (state == MJRefreshStateRefreshing) { 65 | [self.loadingView startAnimating]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | 17 | /** 设置state状态下的文字 */ 18 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 19 | 20 | /** 隐藏刷新状态的文字 */ 21 | @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; 22 | @end 23 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshAutoStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | #pragma mark - 私有方法 47 | - (void)stateLabelClick 48 | { 49 | if (self.state == MJRefreshStateIdle) { 50 | [self beginRefreshing]; 51 | } 52 | } 53 | 54 | #pragma mark - 重写父类的方法 55 | - (void)prepare 56 | { 57 | [super prepare]; 58 | 59 | // 初始化间距 60 | self.labelLeftInset = MJRefreshLabelLeftInset; 61 | 62 | // 初始化文字 63 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle]; 64 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing]; 65 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 66 | 67 | // 监听label 68 | self.stateLabel.userInteractionEnabled = YES; 69 | [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; 70 | } 71 | 72 | - (void)placeSubviews 73 | { 74 | [super placeSubviews]; 75 | 76 | if (self.stateLabel.constraints.count) return; 77 | 78 | // 状态标签 79 | self.stateLabel.frame = self.bounds; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { 87 | self.stateLabel.text = nil; 88 | } else { 89 | self.stateLabel.text = self.stateTitles[@(state)]; 90 | } 91 | } 92 | @end -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackGifFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshBackGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | [self.gifView stopAnimating]; 83 | NSUInteger index = images.count * pullingPercent; 84 | if (index >= images.count) index = images.count - 1; 85 | self.gifView.image = images[index]; 86 | } 87 | 88 | - (void)placeSubviews 89 | { 90 | [super placeSubviews]; 91 | 92 | if (self.gifView.constraints.count) return; 93 | 94 | self.gifView.frame = self.bounds; 95 | if (self.stateLabel.hidden) { 96 | self.gifView.contentMode = UIViewContentModeCenter; 97 | } else { 98 | self.gifView.contentMode = UIViewContentModeRight; 99 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 100 | } 101 | } 102 | 103 | - (void)setState:(MJRefreshState)state 104 | { 105 | MJRefreshCheckState 106 | 107 | // 根据状态做事情 108 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 109 | NSArray *images = self.stateImages[@(state)]; 110 | if (images.count == 0) return; 111 | 112 | self.gifView.hidden = NO; 113 | [self.gifView stopAnimating]; 114 | if (images.count == 1) { // 单张图片 115 | self.gifView.image = [images lastObject]; 116 | } else { // 多张图片 117 | self.gifView.animationImages = images; 118 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 119 | [self.gifView startAnimating]; 120 | } 121 | } else if (state == MJRefreshStateIdle) { 122 | self.gifView.hidden = NO; 123 | } else if (state == MJRefreshStateNoMoreData) { 124 | self.gifView.hidden = YES; 125 | } 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackNormalFooter.h" 10 | #import "NSBundle+MJRefresh.h" 11 | 12 | @interface MJRefreshBackNormalFooter() 13 | { 14 | __unsafe_unretained UIImageView *_arrowView; 15 | } 16 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 17 | @end 18 | 19 | @implementation MJRefreshBackNormalFooter 20 | #pragma mark - 懒加载子控件 21 | - (UIImageView *)arrowView 22 | { 23 | if (!_arrowView) { 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | 31 | - (UIActivityIndicatorView *)loadingView 32 | { 33 | if (!_loadingView) { 34 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 35 | loadingView.hidesWhenStopped = YES; 36 | [self addSubview:_loadingView = loadingView]; 37 | } 38 | return _loadingView; 39 | } 40 | 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | #pragma mark - 重写父类的方法 49 | - (void)prepare 50 | { 51 | [super prepare]; 52 | 53 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 54 | } 55 | 56 | - (void)placeSubviews 57 | { 58 | [super placeSubviews]; 59 | 60 | // 箭头的中心点 61 | CGFloat arrowCenterX = self.mj_w * 0.5; 62 | if (!self.stateLabel.hidden) { 63 | arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWith * 0.5; 64 | } 65 | CGFloat arrowCenterY = self.mj_h * 0.5; 66 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 67 | 68 | // 箭头 69 | if (self.arrowView.constraints.count == 0) { 70 | self.arrowView.mj_size = self.arrowView.image.size; 71 | self.arrowView.center = arrowCenter; 72 | } 73 | 74 | // 圈圈 75 | if (self.loadingView.constraints.count == 0) { 76 | self.loadingView.center = arrowCenter; 77 | } 78 | 79 | self.arrowView.tintColor = self.stateLabel.textColor; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | // 根据状态做事情 87 | if (state == MJRefreshStateIdle) { 88 | if (oldState == MJRefreshStateRefreshing) { 89 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 90 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 91 | self.loadingView.alpha = 0.0; 92 | } completion:^(BOOL finished) { 93 | self.loadingView.alpha = 1.0; 94 | [self.loadingView stopAnimating]; 95 | 96 | self.arrowView.hidden = NO; 97 | }]; 98 | } else { 99 | self.arrowView.hidden = NO; 100 | [self.loadingView stopAnimating]; 101 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 102 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 103 | }]; 104 | } 105 | } else if (state == MJRefreshStatePulling) { 106 | self.arrowView.hidden = NO; 107 | [self.loadingView stopAnimating]; 108 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 109 | self.arrowView.transform = CGAffineTransformIdentity; 110 | }]; 111 | } else if (state == MJRefreshStateRefreshing) { 112 | self.arrowView.hidden = YES; 113 | [self.loadingView startAnimating]; 114 | } else if (state == MJRefreshStateNoMoreData) { 115 | self.arrowView.hidden = YES; 116 | [self.loadingView stopAnimating]; 117 | } 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter : MJRefreshBackFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | /** 设置state状态下的文字 */ 17 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 18 | 19 | /** 获取state状态下的title */ 20 | - (NSString *)titleForState:(MJRefreshState)state; 21 | @end 22 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshBackStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | - (NSString *)titleForState:(MJRefreshState)state { 47 | return self.stateTitles[@(state)]; 48 | } 49 | 50 | #pragma mark - 重写父类的方法 51 | - (void)prepare 52 | { 53 | [super prepare]; 54 | 55 | // 初始化间距 56 | self.labelLeftInset = MJRefreshLabelLeftInset; 57 | 58 | // 初始化文字 59 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle]; 60 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling]; 61 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing]; 62 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 63 | } 64 | 65 | - (void)placeSubviews 66 | { 67 | [super placeSubviews]; 68 | 69 | if (self.stateLabel.constraints.count) return; 70 | 71 | // 状态标签 72 | self.stateLabel.frame = self.bounds; 73 | } 74 | 75 | - (void)setState:(MJRefreshState)state 76 | { 77 | MJRefreshCheckState 78 | 79 | // 设置状态文字 80 | self.stateLabel.text = self.stateTitles[@(state)]; 81 | } 82 | @end 83 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshGifHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshGifHeader.h" 10 | 11 | @interface MJRefreshGifHeader() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshGifHeader 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | // 停止动画 83 | [self.gifView stopAnimating]; 84 | // 设置当前需要显示的图片 85 | NSUInteger index = images.count * pullingPercent; 86 | if (index >= images.count) index = images.count - 1; 87 | self.gifView.image = images[index]; 88 | } 89 | 90 | - (void)placeSubviews 91 | { 92 | [super placeSubviews]; 93 | 94 | if (self.gifView.constraints.count) return; 95 | 96 | self.gifView.frame = self.bounds; 97 | if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { 98 | self.gifView.contentMode = UIViewContentModeCenter; 99 | } else { 100 | self.gifView.contentMode = UIViewContentModeRight; 101 | 102 | CGFloat stateWidth = self.stateLabel.mj_textWith; 103 | CGFloat timeWidth = 0.0; 104 | if (!self.lastUpdatedTimeLabel.hidden) { 105 | timeWidth = self.lastUpdatedTimeLabel.mj_textWith; 106 | } 107 | CGFloat textWidth = MAX(stateWidth, timeWidth); 108 | self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset; 109 | } 110 | } 111 | 112 | - (void)setState:(MJRefreshState)state 113 | { 114 | MJRefreshCheckState 115 | 116 | // 根据状态做事情 117 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 118 | NSArray *images = self.stateImages[@(state)]; 119 | if (images.count == 0) return; 120 | 121 | [self.gifView stopAnimating]; 122 | if (images.count == 1) { // 单张图片 123 | self.gifView.image = [images lastObject]; 124 | } else { // 多张图片 125 | self.gifView.animationImages = images; 126 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 127 | [self.gifView startAnimating]; 128 | } 129 | } else if (state == MJRefreshStateIdle) { 130 | [self.gifView stopAnimating]; 131 | } 132 | } 133 | @end 134 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshNormalHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshNormalHeader.h" 10 | #import "NSBundle+MJRefresh.h" 11 | 12 | @interface MJRefreshNormalHeader() 13 | { 14 | __unsafe_unretained UIImageView *_arrowView; 15 | } 16 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 17 | @end 18 | 19 | @implementation MJRefreshNormalHeader 20 | #pragma mark - 懒加载子控件 21 | - (UIImageView *)arrowView 22 | { 23 | if (!_arrowView) { 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | - (UIActivityIndicatorView *)loadingView 31 | { 32 | if (!_loadingView) { 33 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 34 | loadingView.hidesWhenStopped = YES; 35 | [self addSubview:_loadingView = loadingView]; 36 | } 37 | return _loadingView; 38 | } 39 | 40 | #pragma mark - 公共方法 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | 49 | #pragma mark - 重写父类的方法 50 | - (void)prepare 51 | { 52 | [super prepare]; 53 | 54 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 55 | } 56 | 57 | - (void)placeSubviews 58 | { 59 | [super placeSubviews]; 60 | 61 | // 箭头的中心点 62 | CGFloat arrowCenterX = self.mj_w * 0.5; 63 | if (!self.stateLabel.hidden) { 64 | CGFloat stateWidth = self.stateLabel.mj_textWith; 65 | CGFloat timeWidth = 0.0; 66 | if (!self.lastUpdatedTimeLabel.hidden) { 67 | timeWidth = self.lastUpdatedTimeLabel.mj_textWith; 68 | } 69 | CGFloat textWidth = MAX(stateWidth, timeWidth); 70 | arrowCenterX -= textWidth / 2 + self.labelLeftInset; 71 | } 72 | CGFloat arrowCenterY = self.mj_h * 0.5; 73 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 74 | 75 | // 箭头 76 | if (self.arrowView.constraints.count == 0) { 77 | self.arrowView.mj_size = self.arrowView.image.size; 78 | self.arrowView.center = arrowCenter; 79 | } 80 | 81 | // 圈圈 82 | if (self.loadingView.constraints.count == 0) { 83 | self.loadingView.center = arrowCenter; 84 | } 85 | 86 | self.arrowView.tintColor = self.stateLabel.textColor; 87 | } 88 | 89 | - (void)setState:(MJRefreshState)state 90 | { 91 | MJRefreshCheckState 92 | 93 | // 根据状态做事情 94 | if (state == MJRefreshStateIdle) { 95 | if (oldState == MJRefreshStateRefreshing) { 96 | self.arrowView.transform = CGAffineTransformIdentity; 97 | 98 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 99 | self.loadingView.alpha = 0.0; 100 | } completion:^(BOOL finished) { 101 | // 如果执行完动画发现不是idle状态,就直接返回,进入其他状态 102 | if (self.state != MJRefreshStateIdle) return; 103 | 104 | self.loadingView.alpha = 1.0; 105 | [self.loadingView stopAnimating]; 106 | self.arrowView.hidden = NO; 107 | }]; 108 | } else { 109 | [self.loadingView stopAnimating]; 110 | self.arrowView.hidden = NO; 111 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 112 | self.arrowView.transform = CGAffineTransformIdentity; 113 | }]; 114 | } 115 | } else if (state == MJRefreshStatePulling) { 116 | [self.loadingView stopAnimating]; 117 | self.arrowView.hidden = NO; 118 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 119 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 120 | }]; 121 | } else if (state == MJRefreshStateRefreshing) { 122 | self.loadingView.alpha = 1.0; // 防止refreshing -> idle的动画完毕动作没有被执行 123 | [self.loadingView startAnimating]; 124 | self.arrowView.hidden = YES; 125 | } 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshHeader.h" 10 | 11 | @interface MJRefreshStateHeader : MJRefreshHeader 12 | #pragma mark - 刷新时间相关 13 | /** 利用这个block来决定显示的更新时间文字 */ 14 | @property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); 15 | /** 显示上一次刷新时间的label */ 16 | @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; 17 | 18 | #pragma mark - 状态相关 19 | /** 文字距离圈圈、箭头的距离 */ 20 | @property (assign, nonatomic) CGFloat labelLeftInset; 21 | /** 显示刷新状态的label */ 22 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 23 | /** 设置state状态下的文字 */ 24 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 25 | @end 26 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/MJRefresh/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hant.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "MJRefreshHeaderIdleText" = "下拉可以刷新"; 2 | "MJRefreshHeaderPullingText" = "鬆開立即刷新"; 3 | "MJRefreshHeaderRefreshingText" = "正在刷新數據中..."; 4 | 5 | "MJRefreshAutoFooterIdleText" = "點擊或上拉加載更多"; 6 | "MJRefreshAutoFooterRefreshingText" = "正在加載更多的數據..."; 7 | "MJRefreshAutoFooterNoMoreDataText" = "已經全部加載完畢"; 8 | 9 | "MJRefreshBackFooterIdleText" = "上拉可以加載更多"; 10 | "MJRefreshBackFooterPullingText" = "鬆開立即加載更多"; 11 | "MJRefreshBackFooterRefreshingText" = "正在加載更多的數據..."; 12 | "MJRefreshBackFooterNoMoreDataText" = "已經全部加載完畢"; 13 | 14 | "MJRefreshHeaderLastTimeText" = "最後更新:"; 15 | "MJRefreshHeaderDateTodayText" = "今天"; 16 | "MJRefreshHeaderNoneLastDateText" = "無記錄"; 17 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | 4 | #import "UIScrollView+MJRefresh.h" 5 | #import "UIScrollView+MJExtension.h" 6 | #import "UIView+MJExtension.h" 7 | 8 | #import "MJRefreshNormalHeader.h" 9 | #import "MJRefreshGifHeader.h" 10 | 11 | #import "MJRefreshBackNormalFooter.h" 12 | #import "MJRefreshBackGifFooter.h" 13 | #import "MJRefreshAutoNormalFooter.h" 14 | #import "MJRefreshAutoGifFooter.h" -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | #import 5 | 6 | // 弱引用 7 | #define MJWeakSelf __weak typeof(self) weakSelf = self; 8 | 9 | // 日志输出 10 | #ifdef DEBUG 11 | #define MJRefreshLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define MJRefreshLog(...) 14 | #endif 15 | 16 | // 过期提醒 17 | #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 18 | 19 | // 运行时objc_msgSend 20 | #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) 21 | #define MJRefreshMsgTarget(target) (__bridge void *)(target) 22 | 23 | // RGB颜色 24 | #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 25 | 26 | // 文字颜色 27 | #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) 28 | 29 | // 字体大小 30 | #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] 31 | 32 | // 常量 33 | UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset; 34 | UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; 35 | UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; 36 | UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; 37 | UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; 38 | 39 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; 40 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; 41 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; 42 | UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; 43 | 44 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; 45 | 46 | UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; 47 | UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; 48 | UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; 49 | 50 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; 51 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; 52 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; 53 | 54 | UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; 55 | UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; 56 | UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; 57 | UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; 58 | 59 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText; 60 | UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText; 61 | UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText; 62 | 63 | // 状态检查 64 | #define MJRefreshCheckState \ 65 | MJRefreshState oldState = self.state; \ 66 | if (state == oldState) return; \ 67 | [super setState:state]; 68 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/MJRefreshConst.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | 5 | const CGFloat MJRefreshLabelLeftInset = 25; 6 | const CGFloat MJRefreshHeaderHeight = 54.0; 7 | const CGFloat MJRefreshFooterHeight = 44.0; 8 | const CGFloat MJRefreshFastAnimationDuration = 0.25; 9 | const CGFloat MJRefreshSlowAnimationDuration = 0.4; 10 | 11 | NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; 12 | NSString *const MJRefreshKeyPathContentInset = @"contentInset"; 13 | NSString *const MJRefreshKeyPathContentSize = @"contentSize"; 14 | NSString *const MJRefreshKeyPathPanState = @"state"; 15 | 16 | NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; 17 | 18 | NSString *const MJRefreshHeaderIdleText = @"MJRefreshHeaderIdleText"; 19 | NSString *const MJRefreshHeaderPullingText = @"MJRefreshHeaderPullingText"; 20 | NSString *const MJRefreshHeaderRefreshingText = @"MJRefreshHeaderRefreshingText"; 21 | 22 | NSString *const MJRefreshAutoFooterIdleText = @"MJRefreshAutoFooterIdleText"; 23 | NSString *const MJRefreshAutoFooterRefreshingText = @"MJRefreshAutoFooterRefreshingText"; 24 | NSString *const MJRefreshAutoFooterNoMoreDataText = @"MJRefreshAutoFooterNoMoreDataText"; 25 | 26 | NSString *const MJRefreshBackFooterIdleText = @"MJRefreshBackFooterIdleText"; 27 | NSString *const MJRefreshBackFooterPullingText = @"MJRefreshBackFooterPullingText"; 28 | NSString *const MJRefreshBackFooterRefreshingText = @"MJRefreshBackFooterRefreshingText"; 29 | NSString *const MJRefreshBackFooterNoMoreDataText = @"MJRefreshBackFooterNoMoreDataText"; 30 | 31 | NSString *const MJRefreshHeaderLastTimeText = @"MJRefreshHeaderLastTimeText"; 32 | NSString *const MJRefreshHeaderDateTodayText = @"MJRefreshHeaderDateTodayText"; 33 | NSString *const MJRefreshHeaderNoneLastDateText = @"MJRefreshHeaderNoneLastDateText"; -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/NSBundle+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSBundle (MJRefresh) 12 | + (instancetype)mj_refreshBundle; 13 | + (UIImage *)mj_arrowImage; 14 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value; 15 | + (NSString *)mj_localizedStringForKey:(NSString *)key; 16 | @end 17 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/NSBundle+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSBundle+MJRefresh.h" 10 | #import "MJRefreshComponent.h" 11 | 12 | @implementation NSBundle (MJRefresh) 13 | + (instancetype)mj_refreshBundle 14 | { 15 | static NSBundle *refreshBundle = nil; 16 | if (refreshBundle == nil) { 17 | // 这里不使用mainBundle是为了适配pod 1.x和0.x 18 | refreshBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[MJRefreshComponent class]] pathForResource:@"MJRefresh" ofType:@"bundle"]]; 19 | } 20 | return refreshBundle; 21 | } 22 | 23 | + (UIImage *)mj_arrowImage 24 | { 25 | static UIImage *arrowImage = nil; 26 | if (arrowImage == nil) { 27 | arrowImage = [[UIImage imageWithContentsOfFile:[[self mj_refreshBundle] pathForResource:@"arrow@2x" ofType:@"png"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 28 | } 29 | return arrowImage; 30 | } 31 | 32 | + (NSString *)mj_localizedStringForKey:(NSString *)key 33 | { 34 | return [self mj_localizedStringForKey:key value:nil]; 35 | } 36 | 37 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value 38 | { 39 | static NSBundle *bundle = nil; 40 | if (bundle == nil) { 41 | // (iOS获取的语言字符串比较不稳定)目前框架只处理en、zh-Hans、zh-Hant三种情况,其他按照系统默认处理 42 | NSString *language = [NSLocale preferredLanguages].firstObject; 43 | if ([language hasPrefix:@"en"]) { 44 | language = @"en"; 45 | } else if ([language hasPrefix:@"zh"]) { 46 | if ([language rangeOfString:@"Hans"].location != NSNotFound) { 47 | language = @"zh-Hans"; // 简体中文 48 | } else { // zh-Hant\zh-HK\zh-TW 49 | language = @"zh-Hant"; // 繁體中文 50 | } 51 | } else { 52 | language = @"en"; 53 | } 54 | 55 | // 从MJRefresh.bundle中查找资源 56 | bundle = [NSBundle bundleWithPath:[[NSBundle mj_refreshBundle] pathForResource:language ofType:@"lproj"]]; 57 | } 58 | value = [bundle localizedStringForKey:key value:value table:nil]; 59 | return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; 60 | } 61 | @end 62 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIScrollView (MJExtension) 13 | @property (readonly, nonatomic) UIEdgeInsets mj_inset; 14 | 15 | @property (assign, nonatomic) CGFloat mj_insetT; 16 | @property (assign, nonatomic) CGFloat mj_insetB; 17 | @property (assign, nonatomic) CGFloat mj_insetL; 18 | @property (assign, nonatomic) CGFloat mj_insetR; 19 | 20 | @property (assign, nonatomic) CGFloat mj_offsetX; 21 | @property (assign, nonatomic) CGFloat mj_offsetY; 22 | 23 | @property (assign, nonatomic) CGFloat mj_contentW; 24 | @property (assign, nonatomic) CGFloat mj_contentH; 25 | @end 26 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/UIScrollView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJExtension.h" 11 | #import 12 | 13 | #define SYSTEM_VERSION_GREATER_NOT_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wunguarded-availability-new" 17 | 18 | @implementation UIScrollView (MJExtension) 19 | 20 | - (UIEdgeInsets)mj_inset 21 | { 22 | #ifdef __IPHONE_11_0 23 | if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) { 24 | return self.adjustedContentInset; 25 | } 26 | #endif 27 | return self.contentInset; 28 | } 29 | 30 | - (void)setMj_insetT:(CGFloat)mj_insetT 31 | { 32 | UIEdgeInsets inset = self.contentInset; 33 | inset.top = mj_insetT; 34 | #ifdef __IPHONE_11_0 35 | if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) { 36 | inset.top -= (self.adjustedContentInset.top - self.contentInset.top); 37 | } 38 | #endif 39 | self.contentInset = inset; 40 | } 41 | 42 | - (CGFloat)mj_insetT 43 | { 44 | return self.mj_inset.top; 45 | } 46 | 47 | - (void)setMj_insetB:(CGFloat)mj_insetB 48 | { 49 | UIEdgeInsets inset = self.contentInset; 50 | inset.bottom = mj_insetB; 51 | #ifdef __IPHONE_11_0 52 | if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) { 53 | inset.bottom -= (self.adjustedContentInset.bottom - self.contentInset.bottom); 54 | } 55 | #endif 56 | self.contentInset = inset; 57 | } 58 | 59 | - (CGFloat)mj_insetB 60 | { 61 | return self.mj_inset.bottom; 62 | } 63 | 64 | - (void)setMj_insetL:(CGFloat)mj_insetL 65 | { 66 | UIEdgeInsets inset = self.contentInset; 67 | inset.left = mj_insetL; 68 | #ifdef __IPHONE_11_0 69 | if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) { 70 | inset.left -= (self.adjustedContentInset.left - self.contentInset.left); 71 | } 72 | #endif 73 | self.contentInset = inset; 74 | } 75 | 76 | - (CGFloat)mj_insetL 77 | { 78 | return self.mj_inset.left; 79 | } 80 | 81 | - (void)setMj_insetR:(CGFloat)mj_insetR 82 | { 83 | UIEdgeInsets inset = self.contentInset; 84 | inset.right = mj_insetR; 85 | #ifdef __IPHONE_11_0 86 | if (SYSTEM_VERSION_GREATER_NOT_LESS_THAN(@"11.0")) { 87 | inset.right -= (self.adjustedContentInset.right - self.contentInset.right); 88 | } 89 | #endif 90 | self.contentInset = inset; 91 | } 92 | 93 | - (CGFloat)mj_insetR 94 | { 95 | return self.mj_inset.right; 96 | } 97 | 98 | - (void)setMj_offsetX:(CGFloat)mj_offsetX 99 | { 100 | CGPoint offset = self.contentOffset; 101 | offset.x = mj_offsetX; 102 | self.contentOffset = offset; 103 | } 104 | 105 | - (CGFloat)mj_offsetX 106 | { 107 | return self.contentOffset.x; 108 | } 109 | 110 | - (void)setMj_offsetY:(CGFloat)mj_offsetY 111 | { 112 | CGPoint offset = self.contentOffset; 113 | offset.y = mj_offsetY; 114 | self.contentOffset = offset; 115 | } 116 | 117 | - (CGFloat)mj_offsetY 118 | { 119 | return self.contentOffset.y; 120 | } 121 | 122 | - (void)setMj_contentW:(CGFloat)mj_contentW 123 | { 124 | CGSize size = self.contentSize; 125 | size.width = mj_contentW; 126 | self.contentSize = size; 127 | } 128 | 129 | - (CGFloat)mj_contentW 130 | { 131 | return self.contentSize.width; 132 | } 133 | 134 | - (void)setMj_contentH:(CGFloat)mj_contentH 135 | { 136 | CGSize size = self.contentSize; 137 | size.height = mj_contentH; 138 | self.contentSize = size; 139 | } 140 | 141 | - (CGFloat)mj_contentH 142 | { 143 | return self.contentSize.height; 144 | } 145 | @end 146 | #pragma clang diagnostic pop 147 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 给ScrollView增加下拉刷新、上拉刷新的功能 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | 13 | @class MJRefreshHeader, MJRefreshFooter; 14 | 15 | @interface UIScrollView (MJRefresh) 16 | /** 下拉刷新控件 */ 17 | @property (strong, nonatomic) MJRefreshHeader *mj_header; 18 | @property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header"); 19 | /** 上拉刷新控件 */ 20 | @property (strong, nonatomic) MJRefreshFooter *mj_footer; 21 | @property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer"); 22 | 23 | #pragma mark - other 24 | - (NSInteger)mj_totalDataCount; 25 | @property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); 26 | @end 27 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJRefresh.h" 11 | #import "MJRefreshHeader.h" 12 | #import "MJRefreshFooter.h" 13 | #import 14 | 15 | @implementation NSObject (MJRefresh) 16 | 17 | + (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2 18 | { 19 | method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2)); 20 | } 21 | 22 | + (void)exchangeClassMethod1:(SEL)method1 method2:(SEL)method2 23 | { 24 | method_exchangeImplementations(class_getClassMethod(self, method1), class_getClassMethod(self, method2)); 25 | } 26 | 27 | @end 28 | 29 | @implementation UIScrollView (MJRefresh) 30 | 31 | #pragma mark - header 32 | static const char MJRefreshHeaderKey = '\0'; 33 | - (void)setMj_header:(MJRefreshHeader *)mj_header 34 | { 35 | if (mj_header != self.mj_header) { 36 | // 删除旧的,添加新的 37 | [self.mj_header removeFromSuperview]; 38 | [self insertSubview:mj_header atIndex:0]; 39 | 40 | // 存储新的 41 | [self willChangeValueForKey:@"mj_header"]; // KVO 42 | objc_setAssociatedObject(self, &MJRefreshHeaderKey, 43 | mj_header, OBJC_ASSOCIATION_ASSIGN); 44 | [self didChangeValueForKey:@"mj_header"]; // KVO 45 | } 46 | } 47 | 48 | - (MJRefreshHeader *)mj_header 49 | { 50 | return objc_getAssociatedObject(self, &MJRefreshHeaderKey); 51 | } 52 | 53 | #pragma mark - footer 54 | static const char MJRefreshFooterKey = '\0'; 55 | - (void)setMj_footer:(MJRefreshFooter *)mj_footer 56 | { 57 | if (mj_footer != self.mj_footer) { 58 | // 删除旧的,添加新的 59 | [self.mj_footer removeFromSuperview]; 60 | [self insertSubview:mj_footer atIndex:0]; 61 | 62 | // 存储新的 63 | [self willChangeValueForKey:@"mj_footer"]; // KVO 64 | objc_setAssociatedObject(self, &MJRefreshFooterKey, 65 | mj_footer, OBJC_ASSOCIATION_ASSIGN); 66 | [self didChangeValueForKey:@"mj_footer"]; // KVO 67 | } 68 | } 69 | 70 | - (MJRefreshFooter *)mj_footer 71 | { 72 | return objc_getAssociatedObject(self, &MJRefreshFooterKey); 73 | } 74 | 75 | #pragma mark - 过期 76 | - (void)setFooter:(MJRefreshFooter *)footer 77 | { 78 | self.mj_footer = footer; 79 | } 80 | 81 | - (MJRefreshFooter *)footer 82 | { 83 | return self.mj_footer; 84 | } 85 | 86 | - (void)setHeader:(MJRefreshHeader *)header 87 | { 88 | self.mj_header = header; 89 | } 90 | 91 | - (MJRefreshHeader *)header 92 | { 93 | return self.mj_header; 94 | } 95 | 96 | #pragma mark - other 97 | - (NSInteger)mj_totalDataCount 98 | { 99 | NSInteger totalCount = 0; 100 | if ([self isKindOfClass:[UITableView class]]) { 101 | UITableView *tableView = (UITableView *)self; 102 | 103 | for (NSInteger section = 0; section 11 | 12 | @interface UIView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_x; 14 | @property (assign, nonatomic) CGFloat mj_y; 15 | @property (assign, nonatomic) CGFloat mj_w; 16 | @property (assign, nonatomic) CGFloat mj_h; 17 | @property (assign, nonatomic) CGSize mj_size; 18 | @property (assign, nonatomic) CGPoint mj_origin; 19 | @end 20 | -------------------------------------------------------------------------------- /douyin/MJRefresh/MJRefresh/UIView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIView+MJExtension.h" 11 | 12 | @implementation UIView (MJExtension) 13 | - (void)setMj_x:(CGFloat)mj_x 14 | { 15 | CGRect frame = self.frame; 16 | frame.origin.x = mj_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)mj_x 21 | { 22 | return self.frame.origin.x; 23 | } 24 | 25 | - (void)setMj_y:(CGFloat)mj_y 26 | { 27 | CGRect frame = self.frame; 28 | frame.origin.y = mj_y; 29 | self.frame = frame; 30 | } 31 | 32 | - (CGFloat)mj_y 33 | { 34 | return self.frame.origin.y; 35 | } 36 | 37 | - (void)setMj_w:(CGFloat)mj_w 38 | { 39 | CGRect frame = self.frame; 40 | frame.size.width = mj_w; 41 | self.frame = frame; 42 | } 43 | 44 | - (CGFloat)mj_w 45 | { 46 | return self.frame.size.width; 47 | } 48 | 49 | - (void)setMj_h:(CGFloat)mj_h 50 | { 51 | CGRect frame = self.frame; 52 | frame.size.height = mj_h; 53 | self.frame = frame; 54 | } 55 | 56 | - (CGFloat)mj_h 57 | { 58 | return self.frame.size.height; 59 | } 60 | 61 | - (void)setMj_size:(CGSize)mj_size 62 | { 63 | CGRect frame = self.frame; 64 | frame.size = mj_size; 65 | self.frame = frame; 66 | } 67 | 68 | - (CGSize)mj_size 69 | { 70 | return self.frame.size; 71 | } 72 | 73 | - (void)setMj_origin:(CGPoint)mj_origin 74 | { 75 | CGRect frame = self.frame; 76 | frame.origin = mj_origin; 77 | self.frame = frame; 78 | } 79 | 80 | - (CGPoint)mj_origin 81 | { 82 | return self.frame.origin; 83 | } 84 | @end 85 | -------------------------------------------------------------------------------- /douyin/PrefixHeader.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PrefixHeader.pch 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #ifndef PrefixHeader_pch 10 | #define PrefixHeader_pch 11 | #import "JXUIKit.h" 12 | #import "Masonry.h" 13 | 14 | 15 | // 弱引用 16 | #define MJWeakSelf __weak typeof(self) weakSelf = self; 17 | 18 | #define Color(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 19 | #define kWidth [UIScreen mainScreen].bounds.size.width 20 | #define kHeight [UIScreen mainScreen].bounds.size.height 21 | 22 | //是否iPhoneX 23 | #define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) 24 | #define IS_IOS_11 (([[[[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."] objectAtIndex:0] intValue] >= 11) ? YES : NO) 25 | #define kTabbarHeight ((kDevice_Is_iPhoneX==NO)?49.0:83.0) 26 | #define kNavHeight ((kDevice_Is_iPhoneX==NO)?64.0:88.0) 27 | #define kbottomHeight ((kDevice_Is_iPhoneX==NO)?0:34) 28 | 29 | //获取版本号 30 | #define GET_SYSTEM_VERSION ([[UIDevice currentDevice].systemVersion doubleValue]) 31 | #define IS_IPHONE_5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) 32 | #define IS_IPHONE_6P ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )736 ) < DBL_EPSILON ) 33 | #define kFont(x) IS_IPHONE_5?[UIFont systemFontOfSize:(x-1)]:IS_IPHONE_6P?[UIFont systemFontOfSize:(x+1)]:[UIFont systemFontOfSize:(x)] 34 | 35 | #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)] 36 | // Include any system framework and library headers here that should be included in all compilation units. 37 | // You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. 38 | 39 | #endif /* PrefixHeader_pch */ 40 | -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_blur@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_blur@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_blur@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_blur@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_landscape@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_landscape@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_landscape@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_landscape@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_pause@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_pause@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_pause@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_pause@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_play@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_play@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_play@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_play@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_portrait@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_portrait@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_portrait@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_portrait@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_hightlight@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_hightlight@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_hightlight@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_hightlight@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_normal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_normal@2x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_normal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/douyin/Resource/JPVideoPlayer/JPVideoPlayer.bundle/jp_videoplayer_progress_handler_normal@3x.png -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerCachePath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import 13 | #import "JPVideoPlayerCompat.h" 14 | 15 | UIKIT_EXTERN NSString * _Nonnull const JPVideoPlayerCacheVideoPathForTemporaryFile; 16 | UIKIT_EXTERN NSString * _Nonnull const JPVideoPlayerCacheVideoPathForFullFile; 17 | 18 | NS_ASSUME_NONNULL_BEGIN 19 | 20 | @interface JPVideoPlayerCachePath : NSObject 21 | 22 | /** 23 | * Get the video cache path on version 3.x. 24 | * 25 | * @return The file path. 26 | */ 27 | + (NSString *)videoCachePath; 28 | 29 | /** 30 | * Fetch the video cache path for given key on version 3.x. 31 | * 32 | * @param key A given key. 33 | * 34 | * @return The file path. 35 | */ 36 | + (NSString *)videoCachePathForKey:(NSString *)key; 37 | 38 | /** 39 | * Fetch the video cache path and create video file for given key on version 3.x. 40 | * 41 | * @param key A given key. 42 | * 43 | * @return The file path. 44 | */ 45 | + (NSString *)createVideoFileIfNeedThenFetchItForKey:(NSString *)key; 46 | 47 | /** 48 | * Fetch the index file path for given key on version 3.x. 49 | * 50 | * @param key A given key. 51 | * 52 | * @return The path of index file. 53 | */ 54 | + (NSString *)videoCacheIndexFilePathForKey:(NSString *)key; 55 | 56 | /** 57 | * Fetch the index file path and create video index file for given key on version 3.x. 58 | * 59 | * @param key A given key. 60 | * 61 | * @return The path of index file. 62 | */ 63 | + (NSString *)createVideoIndexFileIfNeedThenFetchItForKey:(NSString *)key; 64 | 65 | @end 66 | 67 | 68 | @interface JPVideoPlayerCachePath(Deprecated) 69 | 70 | /** 71 | * Get the local video cache path for temporary video file. 72 | * 73 | * @param key The unique flag for the given url in this framework. 74 | * 75 | * @return the temporary file path. 76 | */ 77 | + (NSString *)videoCacheTemporaryPathForKey:(NSString *)key JPDEPRECATED_ATTRIBUTE("`videoCacheTemporaryPathForKey:` is deprecated on 3.0.") 78 | 79 | /** 80 | * Get the local video cache path for all full video file. 81 | * 82 | * @param key The unique flag for the given url in this framework. 83 | * 84 | * @return the full file path. 85 | */ 86 | + (NSString *)videoCacheFullPathForKey:(NSString *)key JPDEPRECATED_ATTRIBUTE("`videoCacheFullPathForKey:` is deprecated on 3.0.") 87 | 88 | /** 89 | * Get the local video cache path for all temporary video file on version 2.x. 90 | * 91 | * @return the temporary file path. 92 | */ 93 | + (NSString *)videoCachePathForAllTemporaryFile JPDEPRECATED_ATTRIBUTE("`videoCachePathForAllTemporaryFile` is deprecated on 3.0.") 94 | 95 | /** 96 | * Get the local video cache path for all full video file on version 2.x. 97 | * 98 | * @return the full file path. 99 | */ 100 | + (NSString *)videoCachePathForAllFullFile JPDEPRECATED_ATTRIBUTE("`videoCachePathForAllFullFile` is deprecated on 3.0.") 101 | 102 | @end 103 | 104 | NS_ASSUME_NONNULL_END -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerCompat.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import "JPVideoPlayerCompat.h" 13 | #import 14 | 15 | NSString *const JPVideoPlayerDownloadStartNotification = @"www.jpvideplayer.download.start.notification"; 16 | NSString *const JPVideoPlayerDownloadReceiveResponseNotification = @"www.jpvideoplayer.download.received.response.notification"; 17 | NSString *const JPVideoPlayerDownloadStopNotification = @"www.jpvideplayer.download.stop.notification"; 18 | NSString *const JPVideoPlayerDownloadFinishNotification = @"www.jpvideplayer.download.finished.notification"; 19 | NSString *const JPVideoPlayerErrorDomain = @"com.jpvideoplayer.error.domain.www"; 20 | const NSRange JPInvalidRange = {NSNotFound, 0}; 21 | 22 | void JPDispatchSyncOnMainQueue(dispatch_block_t block) { 23 | if (!block) { return; } 24 | if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) { 25 | block(); 26 | } 27 | else { 28 | dispatch_sync(dispatch_get_main_queue(), block); 29 | } 30 | } 31 | 32 | BOOL JPValidByteRange(NSRange range) { 33 | return ((range.location != NSNotFound) || (range.length > 0)); 34 | } 35 | 36 | BOOL JPValidFileRange(NSRange range) { 37 | return ((range.location != NSNotFound) && range.length > 0 && range.length != NSUIntegerMax); 38 | } 39 | 40 | BOOL JPRangeCanMerge(NSRange range1, NSRange range2) { 41 | return (NSMaxRange(range1) == range2.location) || (NSMaxRange(range2) == range1.location) || NSIntersectionRange(range1, range2).length > 0; 42 | } 43 | 44 | NSString* JPRangeToHTTPRangeHeader(NSRange range) { 45 | if (JPValidByteRange(range)) { 46 | if (range.location == NSNotFound) { 47 | return [NSString stringWithFormat:@"bytes=-%tu",range.length]; 48 | } 49 | else if (range.length == NSUIntegerMax) { 50 | return [NSString stringWithFormat:@"bytes=%tu-",range.location]; 51 | } 52 | else { 53 | return [NSString stringWithFormat:@"bytes=%tu-%tu",range.location, NSMaxRange(range) - 1]; 54 | } 55 | } 56 | else { 57 | return nil; 58 | } 59 | } 60 | 61 | NSError *JPErrorWithDescription(NSString *description) { 62 | assert(description); 63 | if(!description.length){ 64 | return nil; 65 | } 66 | 67 | return [NSError errorWithDomain:JPVideoPlayerErrorDomain 68 | code:0 userInfo:@{ 69 | NSLocalizedDescriptionKey : description 70 | }]; 71 | } -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerControlViews.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import "JPVideoPlayerProtocol.h" 13 | 14 | @class JPVideoPlayerControlProgressView, 15 | JPVideoPlayerControlView; 16 | 17 | NS_ASSUME_NONNULL_BEGIN 18 | 19 | UIKIT_EXTERN NSString *JPVideoPlayerControlProgressViewUserDidStartDragNotification; 20 | UIKIT_EXTERN NSString *JPVideoPlayerControlProgressViewUserDidEndDragNotification; 21 | @interface JPVideoPlayerControlProgressView : UIView 22 | 23 | @property (nonatomic, strong, readonly) NSArray *rangesValue; 24 | 25 | @property (nonatomic, assign, readonly) NSUInteger fileLength; 26 | 27 | @property (nonatomic, assign, readonly) NSTimeInterval totalSeconds; 28 | 29 | @property (nonatomic, assign, readonly) NSTimeInterval elapsedSeconds; 30 | 31 | @property (nonatomic, weak, readonly, nullable) UIView *playerView; 32 | 33 | @property (nonatomic, strong, readonly) UISlider *dragSlider; 34 | 35 | @property (nonatomic, strong, readonly) UIView *cachedProgressView; 36 | 37 | @property (nonatomic, strong, readonly) UIProgressView *trackProgressView; 38 | 39 | @end 40 | 41 | @interface JPVideoPlayerControlBar : UIView 42 | 43 | @property (nonatomic, strong, readonly) UIButton *playButton; 44 | 45 | @property (nonatomic, strong, readonly) UIView *progressView; 46 | 47 | @property (nonatomic, strong, readonly) UILabel *timeLabel; 48 | 49 | @property (nonatomic, strong, readonly) UIButton *landscapeButton; 50 | 51 | - (instancetype)initWithProgressView:(UIView *_Nullable)progressView NS_DESIGNATED_INITIALIZER; 52 | 53 | @end 54 | 55 | @interface JPVideoPlayerControlView : UIView 56 | 57 | @property (nonatomic, strong, readonly) UIView *controlBar; 58 | 59 | @property (nonatomic, strong, readonly) UIImage *blurImage; 60 | 61 | /** 62 | * A designated initializer. 63 | * 64 | * @param controlBar The view abide by the `JPVideoPlayerProgressProtocol`. 65 | * @param blurImage A image on back of controlBar. 66 | * 67 | * @return The current instance. 68 | */ 69 | - (instancetype)initWithControlBar:(UIView *_Nullable)controlBar 70 | blurImage:(UIImage *_Nullable)blurImage NS_DESIGNATED_INITIALIZER; 71 | 72 | @end 73 | 74 | UIKIT_EXTERN const CGFloat JPVideoPlayerProgressViewElementHeight; 75 | @interface JPVideoPlayerProgressView : UIView 76 | 77 | @property (nonatomic, strong, readonly) NSArray *rangesValue; 78 | 79 | @property (nonatomic, assign, readonly) NSUInteger fileLength; 80 | 81 | @property (nonatomic, assign, readonly) NSTimeInterval totalSeconds; 82 | 83 | @property (nonatomic, assign, readonly) NSTimeInterval elapsedSeconds; 84 | 85 | @property (nonatomic, strong, readonly) UIProgressView *trackProgressView; 86 | 87 | @property (nonatomic, strong, readonly) UIView *cachedProgressView; 88 | 89 | @property (nonatomic, strong, readonly) UIProgressView *elapsedProgressView; 90 | 91 | @end 92 | 93 | @interface JPVideoPlayerBufferingIndicator : UIView 94 | 95 | @property (nonatomic, strong, readonly)UIActivityIndicatorView *activityIndicator; 96 | 97 | @property (nonatomic, strong, readonly)UIVisualEffectView *blurView; 98 | 99 | @property (nonatomic, assign, readonly, getter=isAnimating)BOOL animating; 100 | 101 | @end 102 | 103 | @interface JPVideoPlayerView : UIView 104 | 105 | @property (nonatomic, strong, readonly) CALayer *videoContainerLayer; 106 | 107 | @property (nonatomic, strong, readonly) UIView *controlContainerView; 108 | 109 | @property (nonatomic, strong, readonly) UIView *progressContainerView; 110 | 111 | @property (nonatomic, strong, readonly) UIView *bufferingIndicatorContainerView; 112 | 113 | @property (nonatomic, strong, readonly) UIView *userInteractionContainerView; 114 | 115 | @end 116 | 117 | NS_ASSUME_NONNULL_END 118 | -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerDownloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import 13 | #import "JPVideoPlayerCompat.h" 14 | 15 | NS_ASSUME_NONNULL_BEGIN 16 | 17 | @class JPVideoPlayerDownloader, JPResourceLoadingRequestTask; 18 | @class JPResourceLoadingRequestWebTask; 19 | 20 | @protocol JPVideoPlayerDownloaderDelegate 21 | 22 | @optional 23 | 24 | /** 25 | * This method will be called when received response from web, 26 | * this method will execute on main-thread. 27 | * 28 | * @param downloader The current instance. 29 | * @param response The response content. 30 | */ 31 | - (void)downloader:(JPVideoPlayerDownloader *)downloader 32 | didReceiveResponse:(NSURLResponse *)response; 33 | 34 | /** 35 | * This method will be called when received data. 36 | * this method will execute on any-thread. 37 | * 38 | * @param downloader The current instance. 39 | * @param data The received new data. 40 | * @param receivedSize The size of received data. 41 | * @param expectedSize The expexted size of request. 42 | */ 43 | - (void)downloader:(JPVideoPlayerDownloader *)downloader 44 | didReceiveData:(NSData *)data 45 | receivedSize:(NSUInteger)receivedSize 46 | expectedSize:(NSUInteger)expectedSize; 47 | 48 | /**s 49 | * This method will be called when request completed or some error happened other situations. 50 | * this method will execute on main-thread. 51 | * 52 | * @param downloader The current instance. 53 | * @param error The error when request, maybe nil if successed. 54 | */ 55 | - (void)downloader:(JPVideoPlayerDownloader *)downloader 56 | didCompleteWithError:(NSError *)error; 57 | 58 | @end 59 | 60 | @interface JPVideoPlayerDownloader : NSObject 61 | 62 | /** 63 | * Set the default URL credential to be set for request operations. 64 | */ 65 | @property (strong, nonatomic, nullable) NSURLCredential *urlCredential; 66 | 67 | /** 68 | * Set username 69 | */ 70 | @property (strong, nonatomic, nullable) NSString *username; 71 | 72 | /** 73 | * Set password 74 | */ 75 | @property (strong, nonatomic, nullable) NSString *password; 76 | 77 | /** 78 | * The timeout value (in seconds) for the download operation. Default: 15.0s. 79 | */ 80 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 81 | 82 | /** 83 | * The current url, may nil if no download operation. 84 | */ 85 | @property (nonatomic, weak, readonly, nullable) JPResourceLoadingRequestWebTask *runningTask; 86 | 87 | /** 88 | * The current downloaderOptions, may nil if no download operation. 89 | */ 90 | @property (nonatomic, assign, readonly) JPVideoPlayerDownloaderOptions downloaderOptions; 91 | 92 | @property (nonatomic, weak) id delegate; 93 | 94 | /** 95 | * Creates an instance of a downloader with specified session configuration. 96 | * *Note*: `timeoutIntervalForRequest` is going to be overwritten. 97 | * @return new instance of downloader class 98 | */ 99 | - (nonnull instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)sessionConfiguration NS_DESIGNATED_INITIALIZER; 100 | 101 | /** 102 | * Singleton method, returns the shared instance. 103 | * 104 | * @return global shared instance of downloader class. 105 | */ 106 | + (nonnull instancetype)sharedDownloader; 107 | /** 108 | * Start download video data for given url. 109 | * 110 | * @param requestTask A abstract instance packageing the loading request. 111 | * @param downloadOptions The options to be used for this download. 112 | */ 113 | - (void)downloadVideoWithRequestTask:(JPResourceLoadingRequestWebTask *)requestTask 114 | downloadOptions:(JPVideoPlayerDownloaderOptions)downloadOptions; 115 | 116 | /** 117 | * Cancel current download task. 118 | */ 119 | - (void)cancel; 120 | 121 | @end 122 | 123 | NS_ASSUME_NONNULL_END 124 | -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import 13 | #import "JPVideoPlayerCompat.h" 14 | #import 15 | 16 | NS_ASSUME_NONNULL_BEGIN 17 | 18 | @protocol JPVideoPlayerLayoutProtocol 19 | 20 | @required 21 | /** 22 | * This method called when need layout subviews, suggest you layout subviews in this method. 23 | * 24 | * @param constrainedRect The bounds of superview. 25 | * @param nearestViewController The nearest `UIViewController` of view in view tree, 26 | * it be use to fetch `safeAreaInsets` to help layout subviews. 27 | * @param interfaceOrientation The current interface orientation of view. 28 | */ 29 | - (void)layoutThatFits:(CGRect)constrainedRect 30 | nearestViewControllerInViewTree:(UIViewController *_Nullable)nearestViewController 31 | interfaceOrientation:(JPVideoPlayViewInterfaceOrientation)interfaceOrientation; 32 | 33 | @end 34 | 35 | @protocol JPVideoPlayerProtocol 36 | 37 | @optional 38 | /** 39 | * This method will be called when the view as a subview be add to a view. 40 | * 41 | * @note User can hold this view to control player, but remember that do not retain this view, suggest to 42 | * weak hold this view. 43 | * 44 | * @param view The view to control player. 45 | */ 46 | - (void)viewWillAddToSuperView:(UIView *)view; 47 | 48 | /** 49 | * This method will be call when the view be reuse in `UITableView`, 50 | * you need reset progress value in this method for good user experience. 51 | */ 52 | - (void)viewWillPrepareToReuse; 53 | 54 | /** 55 | * This method will be called when the downloader fetched the file length or read from disk. 56 | * 57 | * @warning This method may be call repeatedly when download a video. 58 | * 59 | * @param videoLength The video file length. 60 | */ 61 | - (void)didFetchVideoFileLength:(NSUInteger)videoLength; 62 | 63 | /** 64 | * This method will be called when received new video data from web. 65 | * 66 | * @param cacheRanges The ranges of video data cached in disk. 67 | */ 68 | - (void)cacheRangeDidChange:(NSArray *)cacheRanges; 69 | 70 | /** 71 | * This method will be called when play progress changed. 72 | * 73 | * @param elapsedSeconds The elapsed player time. 74 | * @param totalSeconds The length of the video. 75 | */ 76 | - (void)playProgressDidChangeElapsedSeconds:(NSTimeInterval)elapsedSeconds 77 | totalSeconds:(NSTimeInterval)totalSeconds; 78 | 79 | @end 80 | 81 | @protocol JPVideoPlayerControlProgressProtocol 82 | 83 | /** 84 | * Control progress must implement this method, and implement 85 | * 86 | * @code 87 | * [self willChangeValueForKey:@"userDragging"]; 88 | * _userDragging = userDragging; 89 | * [self didChangeValueForKey:@"userDragging"]; 90 | *@endcode 91 | */ 92 | @property(nonatomic) BOOL userDragging; 93 | 94 | /** 95 | * Control progress must implement this method, and implement 96 | * 97 | * @code 98 | * [self willChangeValueForKey:@"userDragTimeInterval"]; 99 | * _userDragTimeInterval = userDragTimeInterval; 100 | * [self didChangeValueForKey:@"userDragTimeInterval"]; 101 | *@endcode 102 | */ 103 | @property(nonatomic) NSTimeInterval userDragTimeInterval; 104 | 105 | @end 106 | 107 | @protocol JPVideoPlayerBufferingProtocol 108 | 109 | @optional 110 | /** 111 | * This method will be called when player buffering. 112 | */ 113 | - (void)didStartBuffering; 114 | 115 | /** 116 | * This method will be called when player finish buffering and start play. 117 | */ 118 | - (void)didFinishBuffering; 119 | 120 | @end 121 | 122 | @protocol JPVideoPlayerPlaybackProtocol 123 | 124 | @required 125 | /** 126 | * The current playback rate. 127 | */ 128 | @property(nonatomic) float rate; 129 | 130 | /** 131 | * A Boolean value that indicates whether the audio output of the player is muted. 132 | */ 133 | @property(nonatomic) BOOL muted; 134 | 135 | /** 136 | * The audio playback volume for the player, ranging from 0.0 through 1.0 on a linear scale. 137 | */ 138 | @property(nonatomic) float volume; 139 | 140 | /** 141 | * Moves the playback cursor. 142 | * 143 | * @param time The time where seek to. 144 | */ 145 | - (void)seekToTime:(CMTime)time; 146 | 147 | /** 148 | * Call this method to pause playback. 149 | */ 150 | - (void)pause; 151 | 152 | /** 153 | * Call this method to resume playback. 154 | */ 155 | - (void)resume; 156 | 157 | /** 158 | * @return Returns the current time of the current player item. 159 | */ 160 | - (CMTime)currentTime; 161 | 162 | /** 163 | * Call this method to stop play video. 164 | */ 165 | - (void)stopPlay; 166 | 167 | @end 168 | 169 | NS_ASSUME_NONNULL_END 170 | -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/JPVideoPlayerResourceLoader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import 13 | #import 14 | 15 | @class JPVideoPlayerResourceLoader, 16 | JPResourceLoadingRequestWebTask, 17 | JPVideoPlayerCacheFile; 18 | 19 | NS_ASSUME_NONNULL_BEGIN 20 | 21 | @protocol JPVideoPlayerResourceLoaderDelegate 22 | 23 | @required 24 | 25 | /** 26 | * This method will be called when the current instance receive new loading request. 27 | * 28 | * @prama resourceLoader The current resource loader for videoURLAsset. 29 | * @prama requestTask A abstract instance packaging the loading request. 30 | */ 31 | - (void)resourceLoader:(JPVideoPlayerResourceLoader *)resourceLoader 32 | didReceiveLoadingRequestTask:(JPResourceLoadingRequestWebTask *)requestTask; 33 | 34 | @end 35 | 36 | @interface JPVideoPlayerResourceLoader : NSObject 37 | 38 | @property (nonatomic, weak) id delegate; 39 | 40 | /** 41 | * The url custom passed in. 42 | */ 43 | @property (nonatomic, strong, readonly) NSURL *customURL; 44 | 45 | /** 46 | * The cache file take responsibility for save video data to disk and read cached video from disk. 47 | */ 48 | @property (nonatomic, strong, readonly) JPVideoPlayerCacheFile *cacheFile; 49 | 50 | /** 51 | * Convenience method to fetch instance of this class. 52 | * 53 | * @param customURL The url custom passed in. 54 | * 55 | * @return A instance of this class. 56 | */ 57 | + (instancetype)resourceLoaderWithCustomURL:(NSURL *)customURL; 58 | 59 | /** 60 | * Designated initializer method. 61 | * 62 | * @param customURL The url custom passed in. 63 | * 64 | * @return A instance of this class. 65 | */ 66 | - (instancetype)initWithCustomURL:(NSURL *)customURL NS_DESIGNATED_INITIALIZER; 67 | 68 | @end 69 | 70 | NS_ASSUME_NONNULL_END 71 | -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/UITableView+WebVideoCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import "UITableView+WebVideoCache.h" 13 | #import "JPVideoPlayerCompat.h" 14 | #import "JPVideoPlayerSupportUtils.h" 15 | 16 | @interface UITableView() 17 | 18 | @property (nonatomic) JPVideoPlayerTableViewHelper *helper; 19 | 20 | @end 21 | 22 | static const NSString *kJPVideoPlayerScrollViewHelperKey = @"com.jpvideoplayer.scrollview.helper.www"; 23 | @implementation UITableView (WebVideoCache) 24 | 25 | - (void)setJp_delegate:(id )jp_delegate { 26 | self.helper.delegate = jp_delegate; 27 | } 28 | 29 | - (id )jp_delegate { 30 | return self.helper.delegate; 31 | } 32 | 33 | - (UITableViewCell *)jp_playingVideoCell { 34 | return [self.helper playingVideoCell]; 35 | } 36 | 37 | - (void)setJp_tableViewVisibleFrame:(CGRect)jp_tableViewVisibleFrame { 38 | self.helper.tableViewVisibleFrame = jp_tableViewVisibleFrame; 39 | } 40 | 41 | - (CGRect)jp_tableViewVisibleFrame { 42 | return self.helper.tableViewVisibleFrame; 43 | } 44 | 45 | - (void)setJp_scrollPlayStrategyType:(JPScrollPlayStrategyType)jp_scrollPlayStrategyType { 46 | self.helper.scrollPlayStrategyType = jp_scrollPlayStrategyType; 47 | } 48 | 49 | - (JPScrollPlayStrategyType)jp_scrollPlayStrategyType { 50 | return self.helper.scrollPlayStrategyType; 51 | } 52 | 53 | - (void)setJp_unreachableCellDictionary:(NSDictionary *)jp_unreachableCellDictionary { 54 | self.helper.unreachableCellDictionary = jp_unreachableCellDictionary; 55 | } 56 | 57 | - (NSDictionary *)jp_unreachableCellDictionary { 58 | return self.helper.unreachableCellDictionary; 59 | } 60 | 61 | - (void)jp_playVideoInVisibleCellsIfNeed { 62 | [self.helper playVideoInVisibleCellsIfNeed]; 63 | } 64 | 65 | - (void)jp_stopPlayIfNeed { 66 | [self.helper stopPlayIfNeed]; 67 | } 68 | 69 | - (void)jp_handleCellUnreachableTypeInVisibleCellsAfterReloadData { 70 | [self.helper handleCellUnreachableTypeInVisibleCellsAfterReloadData]; 71 | } 72 | 73 | - (void)jp_handleCellUnreachableTypeForCell:(UITableViewCell *)cell 74 | atIndexPath:(NSIndexPath *)indexPath { 75 | [self.helper handleCellUnreachableTypeForCell:cell 76 | atIndexPath:indexPath]; 77 | } 78 | 79 | - (void)jp_scrollViewDidEndDraggingWillDecelerate:(BOOL)decelerate { 80 | [self.helper scrollViewDidEndDraggingWillDecelerate:decelerate]; 81 | } 82 | 83 | - (void)jp_scrollViewDidEndDecelerating { 84 | [self.helper scrollViewDidEndDecelerating]; 85 | } 86 | 87 | - (void)jp_scrollViewDidScroll { 88 | [self.helper scrollViewDidScroll]; 89 | } 90 | 91 | - (BOOL)jp_viewIsVisibleInVisibleFrameAtScrollViewDidScroll:(UIView *)view { 92 | return [self.helper viewIsVisibleInVisibleFrameAtScrollViewDidScroll:view]; 93 | } 94 | 95 | 96 | #pragma mark - Private 97 | 98 | - (JPVideoPlayerTableViewHelper *)helper { 99 | JPVideoPlayerTableViewHelper *_helper = objc_getAssociatedObject(self, &kJPVideoPlayerScrollViewHelperKey); 100 | if(!_helper){ 101 | _helper = [[JPVideoPlayerTableViewHelper alloc] initWithTableView:self]; 102 | objc_setAssociatedObject(self, &kJPVideoPlayerScrollViewHelperKey, _helper, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 103 | } 104 | return _helper; 105 | } 106 | 107 | @end -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/UITableViewCell+WebVideoCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import 13 | 14 | NS_ASSUME_NONNULL_BEGIN 15 | 16 | @interface UITableViewCell (WebVideoCache) 17 | 18 | /** 19 | * The video path url. 20 | * @note The url may a web url or local file url. 21 | */ 22 | @property (nonatomic, nullable) NSURL *jp_videoURL; 23 | 24 | /** 25 | * The view to display video layer. 26 | */ 27 | @property (nonatomic, nullable) UIView *jp_videoPlayView; 28 | 29 | @end 30 | 31 | NS_ASSUME_NONNULL_END -------------------------------------------------------------------------------- /douyin/Resource/JPVideoPlayer/UITableViewCell+WebVideoCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the JPVideoPlayer package. 3 | * (c) NewPan <13246884282@163.com> 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | * 8 | * Click https://github.com/newyjp 9 | * or http://www.jianshu.com/users/e2f2d779c022/latest_articles to contact me. 10 | */ 11 | 12 | #import "UITableViewCell+WebVideoCache.h" 13 | #import 14 | 15 | @implementation UITableViewCell (WebVideoCache) 16 | 17 | - (void)setJp_videoURL:(NSURL *)jp_videoURL { 18 | objc_setAssociatedObject(self, @selector(jp_videoURL), jp_videoURL, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 19 | } 20 | 21 | - (NSURL *)jp_videoURL { 22 | return objc_getAssociatedObject(self, _cmd); 23 | } 24 | 25 | - (void)setJp_videoPlayView:(UIView *)jp_videoPlayView { 26 | objc_setAssociatedObject(self, @selector(jp_videoPlayView), jp_videoPlayView, OBJC_ASSOCIATION_ASSIGN); 27 | } 28 | 29 | - (UIView *)jp_videoPlayView { 30 | return objc_getAssociatedObject(self, _cmd); 31 | } 32 | 33 | @end -------------------------------------------------------------------------------- /douyin/Tools/JXTableView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JXTableView.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/5/18. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MJRefresh.h" 11 | @protocol CustomTableViewDelegete 12 | -(void)getDataWithPage; 13 | @end 14 | @interface JXTableView : UITableView 15 | @property(nonatomic, strong)NSMutableArray *items;//自带数据源 16 | @property(nonatomic, weak)id refreshDelegete; 17 | @property(nonatomic)int index;//加载到第几页 18 | @property(nonatomic)BOOL updating;//是否正在加载 19 | -(void)addMJ; 20 | @end 21 | -------------------------------------------------------------------------------- /douyin/Tools/JXTableView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JXTableView.m 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/5/18. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import "JXTableView.h" 10 | 11 | @implementation JXTableView 12 | - (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style 13 | { 14 | self = [super initWithFrame:frame style:style]; 15 | if (self) { 16 | self.items = [[NSMutableArray alloc] init]; 17 | self.index = 1;//根据自己需求设置-看你们的分页是从0还是1开始 18 | self.updating = NO; 19 | 20 | self.estimatedRowHeight = 0; 21 | self.estimatedSectionHeaderHeight = 0; 22 | self.estimatedSectionFooterHeight = 0; 23 | //适配ios11自适应上导航 安全区域 24 | self.separatorStyle = UITableViewCellSeparatorStyleNone; 25 | SEL selector = NSSelectorFromString(@"setContentInsetAdjustmentBehavior:"); 26 | if ([self respondsToSelector:selector]) { 27 | IMP imp = [self methodForSelector:selector]; 28 | void (*func)(id, SEL, NSInteger) = (void *)imp; 29 | func(self, selector, 2); 30 | 31 | } 32 | self.showsVerticalScrollIndicator = NO; 33 | } 34 | return self; 35 | } 36 | -(void)addMJ 37 | { 38 | MJWeakSelf 39 | self.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{ 40 | // 41 | weakSelf.index++; 42 | [weakSelf getData]; 43 | }]; 44 | 45 | } 46 | 47 | -(void)getData 48 | { 49 | self.updating = YES; 50 | [self.refreshDelegete getDataWithPage]; 51 | } 52 | /* 53 | // Only override drawRect: if you perform custom drawing. 54 | // An empty implementation adversely affects performance during animation. 55 | - (void)drawRect:(CGRect)rect { 56 | // Drawing code 57 | } 58 | */ 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /douyin/Tools/JXUIKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // JXUIKit.h 3 | // PartyBuilding 4 | // 5 | // Created by 主用户 on 2016/11/28. 6 | // Copyright © 2016年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface JXUIKit : NSObject 12 | /**label 背景色 字体颜色 对齐方式 行数 字体大小 文字*/ 13 | +(UILabel *)labelWithBackgroundColor:(UIColor *)backgrountColor textColor:(UIColor *)textColor textAlignment:(NSTextAlignment)textAlignment numberOfLines:(NSInteger)numberOfLines fontSize:(float) size font:(UIFont *)font text:(NSString *)text; 14 | 15 | 16 | /**textField 背景色 字体颜色 是否密文 字体大小 文字 默认文字 文字对齐方式*/ 17 | +(UITextField *)textFieldWithBackgroundColor:(UIColor *)backgrountColor textColor:(UIColor *)textColor secureTextEntry:(BOOL)secureTextEntry fontSize:(float)size font:(UIFont *)font text:(NSString *)text placeholder:(NSString *)placeholder textAlignment:(NSTextAlignment)textAlignment; 18 | 19 | /**textView 背景色 字体颜色 字体大小 文字 文字对齐方式*/ 20 | +(UITextView *)textViewWithBackgroundColor:(UIColor *)backgrountColor textColor:(UIColor *)textColor fontSize:(float)size font:(UIFont *)font text:(NSString *)text textAlignment:(NSTextAlignment)textAlignment; 21 | 22 | /**UIButton 背景色 默认文字颜色 默认文字 选中文字颜色 选中文字 字体大小 默认背景图片 选中背景图片 图片 选中图片*/ 23 | +(UIButton *)buttonWithBackgroundColor:(UIColor *)backgrountColor titleColorForNormal:(UIColor *)titleColorForNormal titleForNormal:(NSString *)titleForNormal titleForSelete:(NSString *)titleForSelete titleColorForSelete:(UIColor *)titleColorForSelete fontSize:(float)size font:(UIFont *)font backgroundImageForNormal:(NSString *)backgroundImageForNormal backgroundImageForSelete:(NSString *)backgroundImageForSelete imageForNormal:(NSString *)imageForNormal imageForSelete:(NSString *)imageForSelete; 24 | 25 | 26 | /**UIButton 默认文字颜色 默认文字 选中文字颜色 选中文字 字体大小 默认背景图片 选中背景图片*/ 27 | +(UIButton *)buttonWithTitleColorForNormal:(UIColor *)titleColorForNormal titleForNormal:(NSString *)titleForNormal titleForSelete:(NSString *)titleForSelete titleColorForSelete:(UIColor *)titleColorForSelete fontSize:(float)size font:(UIFont *)font backgroundImageForNormal:(NSString *)backgroundImageForNormal backgroundImageForSelete:(NSString *)backgroundImageForSelete; 28 | 29 | /**UIButton 背景色 默认文字颜色 默认文字 选中文字颜色 选中文字 字体大小 图片 选中图片*/ 30 | +(UIButton *)buttonWithBackgroundColor:(UIColor *)backgrountColor titleColorForNormal:(UIColor *)titleColorForNormal titleForNormal:(NSString *)titleForNormal titleForSelete:(NSString *)titleForSelete titleColorForSelete:(UIColor *)titleColorForSelete fontSize:(float)size font:(UIFont *)font imageForNormal:(NSString *)imageForNormal imageForSelete:(NSString *)imageForSelete; 31 | 32 | /**UIButton 背景色 默认文字颜色 默认文字 选中文字颜色 选中文字 字体大小*/ 33 | +(UIButton *)buttonWithBackgroundColor:(UIColor *)backgrountColor titleColorForNormal:(UIColor *)titleColorForNormal titleForNormal:(NSString *)titleForNormal titleForSelete:(NSString *)titleForSelete titleColorForSelete:(UIColor *)titleColorForSelete fontSize:(float)size font:(UIFont *)font; 34 | 35 | /**UIButton 默认背景图片 选中背景图片*/ 36 | +(UIButton *)buttonWithBackgroundImageForNormal:(NSString *)backgroundImageForNormal backgroundImageForSelete:(NSString *)backgroundImageForSelete; 37 | 38 | /**UIButton 背景色 图片 选中图片*/ 39 | +(UIButton *)buttonWithBackgroundColor:(UIColor *)backgrountColor imageForNormal:(NSString *)imageForNormal imageForSelete:(NSString *)imageForSelete; 40 | 41 | /**UIImageView 背景色 是否可触摸 图片名字*/ 42 | +(UIImageView *)imageViewWithBackgroundColor:(UIColor *)backgrountColor userInteractionEnabled:(BOOL)userInteractionEnabled imageName:(NSString *)imageName; 43 | 44 | /**UIImageView 背景色 是否可触摸 图片*/ 45 | +(UIImageView *)imageViewWithBackgroundColor:(UIColor *)backgrountColor userInteractionEnabled:(BOOL)userInteractionEnabled image:(UIImage *)image; 46 | 47 | /**UIScrollView 背景色 是否可滑动 容量大小 是否可翻页滑动 是否显示横向滑动条 是否显示竖向滑动条*/ 48 | +(UIScrollView *)scrollViewWithBackgroundColor:(UIColor *)backgrountColor scrollEnabled:(BOOL)scrollEnabled contentSize:(CGSize)size pagingEnabled:(BOOL)pagingEnabled showsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator showsVerticalScrollIndicator:(BOOL)showsVerticalScrollIndicator; 49 | 50 | /**UITableView 背景色 是否可滑动 cell分割样式*/ 51 | +(UITableView *)tableViewWithBackgroundColor:(UIColor *)backgrountColor scrollEnabled:(BOOL)scrollEnabled separatorStyle:(UITableViewCellSeparatorStyle)separatorStyle; 52 | 53 | /**UICollectionView 背景色 是否可滑动 item大小 滚动方向 四周边距 item之间间距 行距 自定义cell的class identifier*/ 54 | +(UICollectionView *)collectionViewWithBackgroundColor:(UIColor *)backgrountColor scrollEnabled:(BOOL)scrollEnabled itemSize:(CGSize)size scrollDirection:(UICollectionViewScrollDirection)scrollDirection sectionInset:(UIEdgeInsets)sectionInset minimumInteritemSpacing:(float)minimumInteritemSpacing minimumLineSpacing:(float)minimumLineSpacing cellClass:(NSString *)cellClass identifier:(NSString *)identifier; 55 | 56 | //切圆角 57 | +(UIView *)ViewcornerRadius:(float)radius andColor:(UIColor *)color andWidth:(float)width :(UIView *)view; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /douyin/View/MainViewNavigitionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewNavigitionView.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainViewNavigitionView : UIView 12 | @property(nonatomic, strong)UIButton *recommendButton;//推荐 13 | @property(nonatomic, strong)UIButton *nearButton;//附近 14 | @property(nonatomic, strong)UIButton *searchButton;//搜索 15 | @end 16 | -------------------------------------------------------------------------------- /douyin/View/MainViewNavigitionView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewNavigitionView.m 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import "MainViewNavigitionView.h" 10 | 11 | @implementation MainViewNavigitionView 12 | -(instancetype)initWithFrame:(CGRect)frame 13 | { 14 | self = [super initWithFrame:frame]; 15 | if (self) { 16 | //中间小白线 17 | UIView *line = [[UIView alloc] init]; 18 | line.backgroundColor = Color(230, 230, 230); 19 | [self addSubview:line]; 20 | MJWeakSelf 21 | [line mas_makeConstraints:^(MASConstraintMaker *make) { 22 | make.centerX.equalTo(weakSelf); 23 | make.bottom.equalTo(weakSelf).offset(-18); 24 | make.width.equalTo(@1); 25 | make.height.equalTo(@8); 26 | }]; 27 | 28 | _recommendButton = [JXUIKit buttonWithBackgroundColor:[UIColor clearColor] titleColorForNormal:Color(230, 230, 230) titleForNormal:@"推荐" titleForSelete:@"推荐" titleColorForSelete:[UIColor whiteColor] fontSize:16 font:nil]; 29 | _recommendButton.tag = 1; 30 | [_recommendButton addTarget:self action:@selector(selectButton:) forControlEvents:UIControlEventTouchUpInside]; 31 | [self chooseButton:_recommendButton]; 32 | [self addSubview:_recommendButton]; 33 | //_recommendButton.sd_layout.rightSpaceToView(line, 5).widthIs(50).heightIs(44).bottomSpaceToView(self, 0); 34 | [_recommendButton mas_makeConstraints:^(MASConstraintMaker *make) { 35 | make.centerX.equalTo(weakSelf).offset(-46); 36 | make.bottom.equalTo(weakSelf); 37 | make.width.equalTo(@50); 38 | make.height.equalTo(@44); 39 | }]; 40 | 41 | _nearButton = [JXUIKit buttonWithBackgroundColor:[UIColor clearColor] titleColorForNormal:Color(230, 230, 230) titleForNormal:@"附近" titleForSelete:@"附近" titleColorForSelete:[UIColor whiteColor] fontSize:16 font:nil]; 42 | [_nearButton addTarget:self action:@selector(selectButton:) forControlEvents:UIControlEventTouchUpInside]; 43 | _nearButton.tag = 2; 44 | [self addSubview:_nearButton]; 45 | //_nearButton.sd_layout.leftSpaceToView(line, 5).widthIs(50).heightIs(44).bottomSpaceToView(self, 0); 46 | [_nearButton mas_makeConstraints:^(MASConstraintMaker *make) { 47 | make.centerX.equalTo(weakSelf).offset(46); 48 | make.bottom.equalTo(weakSelf); 49 | make.width.equalTo(@50); 50 | make.height.equalTo(@44); 51 | }]; 52 | //搜索 53 | _searchButton = [JXUIKit buttonWithBackgroundColor:[UIColor clearColor] imageForNormal:@"sousuo" imageForSelete:nil]; 54 | [self addSubview:_searchButton]; 55 | //_searchButton.sd_layout.rightSpaceToView(self, 20).widthIs(44).heightIs(44).bottomSpaceToView(self, 0); 56 | 57 | [_searchButton mas_makeConstraints:^(MASConstraintMaker *make) { 58 | make.right.equalTo(weakSelf); 59 | make.bottom.equalTo(weakSelf); 60 | make.width.equalTo(@44); 61 | make.height.equalTo(@44); 62 | }]; 63 | } 64 | return self; 65 | } 66 | -(void)selectButton:(UIButton *)button 67 | { 68 | [self resetButton:button.tag == 1?_nearButton:_recommendButton]; 69 | [self chooseButton:button.tag == 1?_recommendButton:_nearButton]; 70 | } 71 | //恢复初始状态 72 | -(void)resetButton:(UIButton *)button 73 | { 74 | button.selected = NO; 75 | button.titleLabel.font = [UIFont systemFontOfSize:16]; 76 | } 77 | //选中按钮 78 | -(void)chooseButton:(UIButton *)button 79 | { 80 | button.selected = YES; 81 | button.titleLabel.font = [UIFont boldSystemFontOfSize:18]; 82 | } 83 | /* 84 | // Only override drawRect: if you perform custom drawing. 85 | // An empty implementation adversely affects performance during animation. 86 | - (void)drawRect:(CGRect)rect { 87 | // Drawing code 88 | } 89 | */ 90 | 91 | @end 92 | -------------------------------------------------------------------------------- /douyin/View/VideoTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoTableViewCell.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/18. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "UIView+WebVideoCache.h" 11 | @interface VideoTableViewCell : UITableViewCell 12 | @property (nonatomic, strong) UIImageView *videoImage; 13 | @property(nonatomic, strong)UIButton *playButton; 14 | -(void)setData:(NSString *)str andIndexPath:(NSIndexPath *)indexPath; 15 | @end 16 | -------------------------------------------------------------------------------- /douyin/View/VideoTableViewCell.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // VideoTableViewCell.m 4 | // douyin 5 | // 6 | // Created by 澜海利奥 on 2018/4/18. 7 | // Copyright © 2018年 江萧. All rights reserved. 8 | // 9 | 10 | #import "VideoTableViewCell.h" 11 | 12 | 13 | @implementation VideoTableViewCell 14 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 15 | if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){ 16 | [self buildUI]; 17 | } 18 | return self; 19 | } 20 | 21 | - (void)buildUI{ 22 | _videoImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)]; 23 | //_videoImage.contentMode = UIViewContentModeScaleAspectFill; 24 | _videoImage.userInteractionEnabled = YES; 25 | [self.contentView addSubview:self.videoImage]; 26 | 27 | 28 | 29 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, kHeight)]; 30 | view.backgroundColor = [UIColor clearColor]; 31 | view.userInteractionEnabled = YES; 32 | [self.contentView addSubview:view]; 33 | self.jp_videoPlayView = view; 34 | //self.jp_videoPlayView.jp_videoPlayerDelegate = self; 35 | 36 | 37 | _playButton = [JXUIKit buttonWithBackgroundColor:RGBACOLOR(0, 0, 0, 0) imageForNormal:@"" imageForSelete:@"xuexi_yinpin_btn_bofang"]; 38 | [self.contentView addSubview:_playButton]; 39 | _playButton.frame = CGRectMake(0, 0, kWidth, kHeight); 40 | 41 | 42 | } 43 | -(void)setData:(NSString *)str andIndexPath:(NSIndexPath *)indexPath 44 | { 45 | self.playButton.selected = NO; 46 | //self.jp_videoPlayView.alpha = 0; 47 | [_videoImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d",(int)indexPath.row%3+1]]]; 48 | self.selectionStyle = UITableViewCellSelectionStyleNone; 49 | self.jp_videoURL = [NSURL URLWithString:str]; 50 | 51 | [self.playButton setTitle:[NSString stringWithFormat:@"%d",(int)indexPath.row] forState:0]; 52 | self.playButton.tag = indexPath.row; 53 | 54 | } 55 | //-(BOOL)shouldShowBlackBackgroundBeforePlaybackStart 56 | //{ 57 | // return NO; 58 | //} 59 | - (void)awakeFromNib { 60 | [super awakeFromNib]; 61 | // Initialization code 62 | } 63 | 64 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 65 | [super setSelected:selected animated:animated]; 66 | 67 | // Configure the view for the selected state 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /douyin/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JXRefreshViewController.h" 11 | @interface ViewController : JXRefreshViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /douyin/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. 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 | -------------------------------------------------------------------------------- /douyin/视频/发布视频/PublishVideoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PublishVideoViewController.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/19. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PublishVideoViewController : UIViewController 12 | @property(nonatomic, copy)NSURL *videoPath; 13 | @property(nonatomic, copy)UIImage *coverImage; 14 | @end 15 | -------------------------------------------------------------------------------- /douyin/视频/发布视频/views/JXCustomTextView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JXCustomTextView.h 3 | // YXProductDemo 4 | // 5 | // Created by 江萧 on 2017/2/20. 6 | // Copyright © 2017年 蚁象ios. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JXCustomTextView : UIView 12 | @property(nonatomic, strong)UILabel *placeholderLabel;// 13 | @property(nonatomic, strong)UITextView *textView;//评价 14 | @property(nonatomic, copy)void(^textViewEdit)(bool isEdit); 15 | -(void)initSubViewWithBackgroundColor:(UIColor *)color placeholder:(NSString *)placeholder font:(UIFont *)font textColor:(UIColor *)textColor placeholderColor:(UIColor *)placeholderColor; 16 | @end 17 | -------------------------------------------------------------------------------- /douyin/视频/发布视频/views/JXCustomTextView.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // JXCustomTextView.m 4 | // YXProductDemo 5 | // 6 | // Created by 江萧 on 2017/2/20. 7 | // Copyright © 2017年 蚁象ios. All rights reserved. 8 | // 9 | 10 | #import "JXCustomTextView.h" 11 | @interface JXCustomTextView() 12 | { 13 | NSString *_placeholder; 14 | 15 | } 16 | @end 17 | @implementation JXCustomTextView 18 | @synthesize placeholderLabel,textView; 19 | -(void)initSubViewWithBackgroundColor:(UIColor *)color placeholder:(NSString *)placeholder font:(UIFont *)font textColor:(UIColor *)textColor placeholderColor:(UIColor *)placeholderColor 20 | { 21 | self.backgroundColor = color; 22 | _placeholder = placeholder; 23 | 24 | placeholderLabel =[JXUIKit labelWithBackgroundColor:RGBACOLOR(0, 0, 0, 0) textColor:placeholderColor textAlignment:NSTextAlignmentLeft numberOfLines:1 fontSize:0 font:font text:placeholder]; 25 | [self addSubview:placeholderLabel]; 26 | MJWeakSelf 27 | [placeholderLabel mas_makeConstraints:^(MASConstraintMaker *make) { 28 | make.width.equalTo(@200); 29 | make.height.equalTo(@20); 30 | make.left.equalTo(@6); 31 | make.top.equalTo(@9); 32 | }]; 33 | textView = [[UITextView alloc] init]; 34 | textView.backgroundColor = RGBACOLOR(0, 0, 0, 0); 35 | textView.textColor = textColor; 36 | textView.delegate = self; 37 | textView.text = @""; 38 | textView.font = font; 39 | [self addSubview:textView]; 40 | [textView mas_makeConstraints:^(MASConstraintMaker *make) { 41 | make.right.equalTo(@(-5)); 42 | make.height.equalTo(@100); 43 | make.left.equalTo(@5); 44 | make.top.equalTo(@5); 45 | }]; 46 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillBeHidden:) name:UIKeyboardWillHideNotification object:nil]; 47 | } 48 | -(BOOL)textViewShouldBeginEditing:(UITextView *)textView 49 | { 50 | if (self.textViewEdit) { 51 | self.textViewEdit(YES); 52 | } 53 | 54 | return YES; 55 | } 56 | 57 | -(void)textViewDidChange:(UITextView *)textView 58 | { 59 | if (self.textView.text.length>0) { 60 | placeholderLabel.text = @""; 61 | 62 | }else{ 63 | placeholderLabel.text = _placeholder; 64 | 65 | } 66 | 67 | } 68 | -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text 69 | { 70 | 71 | return YES; 72 | } 73 | -(void)textViewDidEndEditing:(UITextView *)textView 74 | { 75 | 76 | //self.textViewEdit(NO); 77 | } 78 | -(void)keyboardWillBeHidden:(NSNotification*)aNotification 79 | 80 | { 81 | if (self.textViewEdit) { 82 | self.textViewEdit(NO); 83 | } 84 | } 85 | - (void)dealloc 86 | { 87 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 88 | } 89 | /* 90 | // Only override drawRect: if you perform custom drawing. 91 | // An empty implementation adversely affects performance during animation. 92 | - (void)drawRect:(CGRect)rect { 93 | // Drawing code 94 | } 95 | */ 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /douyin/视频/发布视频/views/VideoView.h: -------------------------------------------------------------------------------- 1 | // 2 | // VideoView.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/19. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VideoView : UIView 12 | @property(nonatomic, strong)UIButton *videoButton;// 13 | @end 14 | -------------------------------------------------------------------------------- /douyin/视频/发布视频/views/VideoView.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // VideoView.m 4 | // douyin 5 | // 6 | // Created by 澜海利奥 on 2018/4/19. 7 | // Copyright © 2018年 江萧. All rights reserved. 8 | // 9 | 10 | #import "VideoView.h" 11 | 12 | @implementation VideoView 13 | -(instancetype)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | 18 | _videoButton = [[UIButton alloc] init]; 19 | _videoButton.backgroundColor = RGBACOLOR(255, 0, 0, 0.3); 20 | //[_videoButton setBackgroundImage:self.coverImage forState:0]; 21 | [self addSubview:_videoButton]; 22 | 23 | [_videoButton mas_makeConstraints:^(MASConstraintMaker *make) { 24 | make.left.equalTo(@0); 25 | make.top.equalTo(@0); 26 | make.bottom.equalTo(@0); 27 | make.right.equalTo(@0); 28 | }]; 29 | } 30 | return self; 31 | } 32 | /* 33 | // Only override drawRect: if you perform custom drawing. 34 | // An empty implementation adversely affects performance during animation. 35 | - (void)drawRect:(CGRect)rect { 36 | // Drawing code 37 | } 38 | */ 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /douyin/视频/选封面/ChoseCoverViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChoseCoverViewController.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/19. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ChoseCoverViewController : UIViewController 12 | @property(nonatomic, copy)NSURL *videoPath; 13 | @end 14 | -------------------------------------------------------------------------------- /douyin/视频/选封面/CoverImageCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CoverImageCollectionViewCell.h 3 | // douyin 4 | // 5 | // Created by 澜海利奥 on 2018/4/19. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CoverImageCollectionViewCell : UICollectionViewCell 12 | @property(nonatomic,strong)UIImageView *image; 13 | @end 14 | -------------------------------------------------------------------------------- /douyin/视频/选封面/CoverImageCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // CoverImageCollectionViewCell.m 4 | // douyin 5 | // 6 | // Created by 澜海利奥 on 2018/4/19. 7 | // Copyright © 2018年 江萧. All rights reserved. 8 | // 9 | 10 | #import "CoverImageCollectionViewCell.h" 11 | 12 | @implementation CoverImageCollectionViewCell 13 | -(instancetype)initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | if (self) { 17 | 18 | self.backgroundColor = [UIColor blackColor]; 19 | //图标 20 | _image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 80)]; 21 | _image.contentMode = UIViewContentModeScaleAspectFill; 22 | _image.clipsToBounds = YES; 23 | 24 | [self addSubview:_image]; 25 | 26 | 27 | 28 | } 29 | return self; 30 | } 31 | @end 32 | -------------------------------------------------------------------------------- /douyinTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /douyinTests/douyinTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // douyinTests.m 3 | // douyinTests 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface douyinTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation douyinTests 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 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | // 释放测试用例的资源代码,这个方法会每个测试用例执行后调用 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample { 30 | // This is an example of a functional test case. 31 | // Use XCTAssert and related functions to verify your tests produce the correct results. 32 | // 测试用例的例子,注意测试用例一定要test开头 33 | } 34 | 35 | - (void)testPerformanceExample { 36 | // This is an example of a performance test case. 37 | [self measureBlock:^{ 38 | // Put the code you want to measure the time of here. 39 | // 需要测试性能的代码 40 | for (int i = 0; i<10000; i++) { 41 | 42 | NSLog(@"dd"); 43 | } 44 | }]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /douyinUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /douyinUITests/douyinUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // douyinUITests.m 3 | // douyinUITests 4 | // 5 | // Created by 澜海利奥 on 2018/4/12. 6 | // Copyright © 2018年 江萧. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface douyinUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation douyinUITests 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 | -------------------------------------------------------------------------------- /erweima.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/erweima.png -------------------------------------------------------------------------------- /footeRefresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/footeRefresh.gif -------------------------------------------------------------------------------- /img1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/img1.jpeg -------------------------------------------------------------------------------- /jiawo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qlyx/douyinRefresh/1451d87e2a19b99e69bf3464063797748f08549d/jiawo.jpg --------------------------------------------------------------------------------