CollectioniOS aggregates some basic modules of project construction, saves developers’ time, assists in rapid project construction, and can meet the basic realization of a project.

Making address:Github.com/usernameyan…
Letter Address:www.jianshu.com/p/a445521e7…

Introduction of frameworks

  • Pod ‘CollectioniOS’, ‘~ > 1.1.3’

Updated instructions

v1.1.3

2. Solve the problem that the default image in the library cannot be displayed

v1.0.9

1. Add DataManager to enable the integration of Http data requests, UserDefaults, File and SQLite. Remove YYHttpUtils 2. Add YYTagView 3. Add MVP

V1.0.8 (Add the following features)

1. Basic application configuration: Intra-application internationalization language configuration and application name internationalization. 2. UTTableView/UICollectionView encapsulation and general usage. YYNavigationBar: encapsulation and use of the top navigation bar. 4.YYAutoLayout: Use of automatic layout. 5.YYTabBar: Encapsulation and use of the bottom paging navigation bar. 6. Packaging and use of YYPageView. 7.YYPageMenu: Encapsulation and use of sliding menus. YYRefresh: pull down refresh/pull up load more control encapsulation and use. 9.YYImageLoader: network image loading (can load ordinary network images, GIF, can set the cache time, cache size). YYDataShowView: data loading display style (no data, network error, loading)

• App Transport Security Settings->Allow Arbitrary Loads(set to YES)

Project introduction

The overall effect

The article directories

1. Apply the basic configuration

  • In-application internationalization language configuration
  • Application name internationalization

2. Encapsulation of UTTableView

  • Through YYTableViewManager for unified management of UITableView
  • Custom divider
  • List adds a header view
  • Implement ExpandableList
  • The Cell implements adaptive height
  • UITableView adds a retractable header
  • Delete the Cell by sliding
  • Implementation of multiple layouts
  • UITableView implements classification effects

3. Use the basis of UICollectionView/UIScrollView

  • UICollectionView Universal layout, you can quickly set the number of lines, height
  • UICollectionView adds a retractable header
  • UIScrollView adds a retractable header

YYNavigationBar: The top navigation bar

  • YYNavigationBar encapsulation use

5.YYAutoLayout: Automatic layout

  • Simple use of YYAutoLayout

YYTabBar: The bottom paging navigation bar

  • TabBar basic sample, custom selected color, default TabBar subscript, click spring effect
  • TabBar is used in combination with NavigationBar
  • TabBar irregular sorting and custom click events
  • Background color effect (without title), background color with spring selection effect (without title), background color highlight (without title), hint the user to click
  • TabBar Default prompt box (TabBarBadgeValue content Settings, prompt color, hide)
  • Custom TabBarItemView, can set font color, picture color, set custom prompt box, prompt action

7.YYPageView: Picture rotation

  • Package use of YYPageView

8.YYPageMenu: Slide menu

  • YYPageMenu packaging use

9.YYRefresh: Pull down to refresh/pull up to load more

  • Default pull-down refresh/pull-up loading for more style
  • More style of custom pull-down refresh/pull-up loading

YYImageLoader: Loading network images

  • Loading normal images
  • Loading GIF figure
  • Customize the parameters for loading images

11.YYDialog: General prompt box

  • Use of the prompt box
  • The use of loading boxes
  • A bigger tip

12. Use of DataManager (Http, UserDefaults, File, SQLite)

  • Http
  • UserDefaults
  • File
  • SQLite

13.YYDataShowView: Data loading display page

  • Use of common data load prompts

14. YYTagView

15. MVP

16. General utility classes

The specific use

1. Apply basic configuration

1. Configure the in-app internationalization language

Implementation process:
1. Create a Strings File in the project named Localizable. Strings 2. Select Localizable. Strings file click localizaiton and select the desired language 3. If you don't have the required languages, go to PROJECT -> Files -> Info -> find Localizations and add 4. Content fetching and system language switching using the InternationalUtils class: (1) in the AppDelegate through InternationalUtils. GetInstance. InitUserLanguage initialized () (2) through InternationalUtils. GetInstance. Get string (name) for Localizable. String string matching content (3) through InternationalUtils. GetInstance. SetLanguage (LanguageType, rootViewController) to switch from the language, Attention is required to root Controller. (4) by InternationalUtils getCurrentLanguage () gets the current languageCopy the code
2. Apply name internationalization
Create a Strings File and name it infoList. Strings. (2) Select the created File and click Localize to select the desired language. (3) Configure Infolist. Strings: CFBundleDisplayName =Copy the code

Two, UTTableView encapsulation use

1. YYTableViewManager use
  • Manage UITableView through YYTableViewManager:

    Let manager = YYTableViewManager(tableView: self.tableView)Copy the code
  • YYTableViewManager is composed of YYTableViewSection(the head of each UITabView item group) and Cell: YYTableViewItem and YYTableViewCell

  • YYTableViewManager

attribute role
register(_ nibClass: AnyClass, _ item: AnyClass, _ bundle: Bundle = Bundle.main Register YYTabViewCell and YYTabViewItem
numberOfSections(in _: UITableView) The subscript of the current Section
numberOfSections(in _: UITableView) The subscript of the current Section
add(section: YYTableViewSection) Add Section header view
remove(section: Any) Remove the Section header view
removeAllSections() Remove all Section header views
reloadData() Reload UITabView data
  • YYTableViewSection
attribute role
headerHeight Head view height
footerHeight Tail view height
init() Use the default header view, which is not displayed by default if no header parameters are set
init(headerView: UIView!) Added custom header view
init(footerView: UIView?) Added custom tail view
init(headerView: UIView? , footerView: UIView?) Added custom head view and tail view
add(item: YYTableViewItem) Add the item under the header view
remove(item: YYTableViewItem) Removes the item under the header view
removeAllItems() Removes all items under the header view
replaceItemsFrom(array: [YYTableViewItem]!) Replaces all items under the header view
insert(_ item: YYTableViewItem! , afterItem: YYTableViewItem, animate: UITableView.RowAnimation = .automatic) Inserts a new item after an item
insert(_ items: [YYTableViewItem], afterItem: YYTableViewItem, animate: UITableView.RowAnimation = .automatic) Inserts an item array after an item
delete(_ itemsToDelete: [YYTableViewItem], animate: UITableView.RowAnimation = .automatic) Deletes an item from the header view
reload(_ animation: UITableView.RowAnimation) Reload data under Section groups
  • YYTableViewCell
attribute role
item YYTableItem bound to Cell during register is mainly for data transfer
cellWillAppear() This callback is called when the Cell is displayed
cellDidDisappear() This callback is called when the Cell disappears
setSelected() Cell Sets the selection status
  • YYTableViewItem
attribute role
tableViewManager The binding of YYTableViewManager
section The binding of YYTableViewSection
cellTitle Set the field for the default Cell header
cellHeight The height of the Cell
cellStyle The style of the Cell
func setSelectionHandler(selectHandler: YYTableViewItemBlock?) Click event callback for Item
setDeletionHandler(deletionHandler: YYTableViewItemBlock?) Item deletion event callback
separatorInset The inside margin of the dividing line
editingStyle Edit status of Item
isHideSeparator Whether Item hides the dividing line
separatorLeftMargin The margin of the dividing line
indexPath The Item of the subscript
reload(_ animation: UITableView.RowAnimation) Item data is reloaded
delete(_ animation: UITableView.RowAnimation = .automatic) Delete Item data
updateHeight() Update the height
autoHeight() Automatic altitude calculation
  • Basic usage:

    Let Manager = YYTableViewManager(tableView: Self.tableview) // Add a header view let section = YYTableViewSection() manager.add(section: Section) / / registered YYTableViewCell and YYTableViewItem manager. Register (CommonTableViewCell. Self, Commontableitem.self) //Section Add item section.add(item: item) manager.reloadData()Copy the code
  • Customize YYTableViewCell and YYTableViewItem

    Class CommonTableItem: YYTableViewItem {/ / var desc: some custom data structure String! / / custom highly override init () {super. The init () cellHeight = 30}} class CommonTableViewCell: YYTableViewCell {override init (style:  UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) } required init? (coder aDecoder: NSCoder) { super.init(coder: Override func cellWillAppear() {let item = self.item as! CommonTableItem } }Copy the code
  • Custom divider

    Override func draw(_ rect) override func draw(_ rect) CGRect) {/ / to get drawing context guard let the context = UIGraphicsGetCurrentContext () else / / # FF4500 {return} context.setStrokeColor(UIColor.colorWithHexString("#D2D3D5").cgColor) context.stroke(CGRect(x:0, y: rect.size.height, width: rect.size.width, height:1)) }Copy the code
  • List adds a header view

    for i in 0 ... 8 {
          let headerView:SelectionHeader=SelectionHeader.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40))
          headerView.setContent(con: "Header " + String(i))
          let section = YYTableViewSection.init(headerView: headerView)
          manager.add(section: section)
          for j in 0 ... 4 {
              section.add(item: YYTableViewItem(title: "Header " + String(i) + " Row " + String(j)))
          }
      }
    Copy the code
  • Implement ExpandableList

    // Level 0 let Item0 = ExpanableListItem1() Item0. Level = 0 section.add(item: Item0) // If isExpand is true, the next level item must be added to section Item0. IsExpand = true // level 1 for _ in 0.. < 3 {let item1 = ExpanableListItem2() // level Is used for record levels only. Item1. level = 1 Item1. isExpand = false section.add(item: item1) item0.arrNextLevel.append(item1) // level 2 for _ in 0 .. < 3 {let item2 = ExpanableListItem3() Is behind you don't have to add the item to section item2. IsExpand = false item1. ArrNextLevel. Append (item2)}}Copy the code
  • The Cell implements adaptive height

    Let item = CommonTableItem() item.desc= STR as? String item.autoheight (manager)Copy the code
  • UITableView adds a retractable header

    Tableview.addsubview (ScaleHeaderView(Frame: stretchyHeaderView) self.view.bounds))Copy the code
  • Delete the Cell by sliding

    for _ in 0 .. < 20 {let item = CommonTableItem() item.desc=" left slide to delete item" item.editingStyle =. SetDeletionHandler ({[weak self] (item) in self?. DeleteConfirm (item: item as! CommonTableItem) }) }Copy the code
  • Implementation of multiple layouts

    let section = YYTableViewSection() manager.add(section: section) manager.register(PictureCell.self, PictureItem.self) manager.register(TextCell.self, TextItem.self) for index in 0... 30{ if(index%2==0){ let picture = PictureItem() picture.content="" picture.autoHeight(manager) section.add(item: picture) }else{ let textItem = TextItem() textItem.content="" textItem.autoHeight(manager) section.add(item: textItem) } }Copy the code
  • UITableView classification effect specific implementation see demo code implementation

Three, use the basis of UICollectionView/UIScrollView

1. Quick use of UICollectionView
  • CommonCollectionViewLayout
attribute role
init(lineSpacing: CGFloat, columnSpacing: CGFloat, sectionInsets: UIEdgeInsets) The layout is initialized, and row spacing, column spacing, and box margins can be set
  • CommonCollectionViewLayoutDelegate
attribute role
columnOfLayout(_ collectionView: UICollectionView) Sets the number of columns in the UICollectionView
itemHeight(_ collectionView: UICollectionView, layout commonCollectionViewLayout: CommonCollectionViewLayout, heightForItemAt indexPath: IndexPath) Sets the height of item
Using the step
  • (1) set CommonCollectionViewLayout

    let flowLayout = CommonCollectionViewLayout.init(lineSpacing: 10, columnSpacing:10, sectionInsets: UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)) flowLayout! .delegate=self collectionView=UICollectionView(frame: self.view.frame, collectionViewLayout: self.flowLayout!) collectionView! .dataSource=self self.collectionView! .delegate=self // Register cell self.collectionView! .register(CommonUICollectionViewCell.classForCoder(), forCellWithReuseIdentifier: reuseidentifier)Copy the code
  • (1) achieve CommonCollectionViewLayoutDelegate

    extension CommonUICollectionViewController:CommonCollectionViewLayoutDelegate,UICollectionViewDelegate, UICollectionViewDataSource{
      func columnOfLayout(_ collectionView: UICollectionView) -> Int {
        code
      }
      func itemHeight(_ collectionView: UICollectionView, layout commonCollectionViewLayout: CommonCollectionViewLayout, heightForItemAt indexPath: IndexPath) -> CGFloat {
        code
      }
    }
    Copy the code
2. Increased UICollectionView/UIScrollView scalable head

See the use of UITableView above

YYNavigationBar: the top navigation bar

1.YYNavigationBar basic properties
attribute role
setHidden(…) Hide the NavigationBar
setAlpha(…) Set NavigationBar transparency
setBarBackgroundColor(…) Set the NavigationBar background color
setTitleColor(…) Set the NavigationBar’s title color
setTitleSize(…) Set the NavigationBar title size
setShadowImage(…) Set the NavigationBar’s shadow image
setShadowHidden(…) Sets whether the NavigationBar shadow is hidden
setShadow(…) Set the NavigationBar shadow
setTitleTextAttributes(…) Set the Attributes for the NavigationBar’s title
setTranslucent(…) Set NavigationBar transparency
setBarStyle(…) Set NavigationBar to style
setBackgroundImage(…) Set NavigationBar background image, which overwrites the background color
setTitle(…) Set the NavigationBar title
setBackBarButtonItem(…) Set NavigationBar to return Item
setBackBarButtonItem(…) Set NavigationBar to return Item
setLeftButtonItem(…) Set NavigationBar left menu Item
setLeftButtonItems(…) Set NavigationBar left menu Item
setRightButtonItem(…) Set NavigationBar menu Item to the right
setRightButtonItems(…) Set the NavigationBar left menu Item array
2. Set YYNavigationBar global Configuration
attribute role
isHidden Hide the NavigationBar
alpha NavigationBar transparency
tintColor NavigationBar title color
shadowImage Set the NavigationBar’s shadow image
isShadowHidden Hide the shadow of NavigationBar
titleTextAttributes The NavigationBar Attributes
isTranslucent Make NavigationBar transparent
setBackgroundImage Set the NavigationBar background image
3. Chain use
NavigationUtils
        .with(controller: self)
        .setBarBackgroundColor(barTintColor: UIColor.red)
        .setTitle(title: InternationalUtils.getInstance.getString("nav_use"))
        .setBackBarButtonItem(style: .image(UIImage(named: "back_btn")),tintColor: UIColor.gray)
        .build(
Copy the code

Five, YYAutoLayout: automatic layout

The chain using
centerLabel
        .centerX(equalTo: view.yy_centerX)
        .centerY(equalTo: view.yy_centerY)
        .width(80)
        .height(40)
        .build()
Copy the code

YYTabBar: bottom paging navigation bar

1. TabBarBasicParamBuilder basic properties
attribute role
with(…) The initial method of TabBarBasicParamBuilder that sets the TabBar image and title
defultStyle() Gets the defaultStyle Settings, the following attributes belong to defaultStyle()
setTextColor(…) Sets the color of the unselected title
setSelectTextColor(…) Set the color of the selection title
setImgColor(…) Sets the color of an unselected image
setSelectImgColor(…) Settings select picture color
bouncesAnimationStyle() Set spring animation
setRemindUseClickIndex(…) Set user alert click subscript
irregularity() Irregularity TabBarItem: Attribute to defultStyle(), attribute to irregularity()
setIrregularityIndex(…) Sets the index of an irregular TabBarItem
setIrregularityBorderColor(…) Set the irregular icon BorderColor
setIrregularityBorderWidth(…) Set the outer width of an irregular TabBarItem
setIrregularityBackgroundColor(…) Set the irregular TabBarItem background color
retunDefaultStyle() Return defuletStyle
backgroundColorWithoutTitlesAnimationStyle() Set TarBarItem background color with no title, ownership defultStyle (), the following property ownership backgroundColorWithoutTitlesAnimationStyle ()
irregularity() Irregularity TabBarItem: Attribute to defultStyle(), attribute to irregularity()
setItemBgColor(…) Sets the unselected TabBarItem background color
setSelectItemBgColor(…) Set select TabBarItem background color
retunDefaultStyle() Return defuletStyle
cumstomStyle() Get custom style Settings, following attributes to cumstomStyle()
setCumstonTabBarItemView(…) Sets the custom TarBarItem array
2.TabBarSetting
attribute role
init(…) Initialize TabBarItem according to TabBarBasicParamBuilder
setTabBarBackgroundColor(…) Sets the TarBar background color
setTabBarBackgroundImage(…) Set the TarBar background image
setShouldHijackHandler(…) Set TarBarItem to hit callback, returning true for interception and false for no interception
setDidHijackhHandler(…) Click callback processing
setDefaultTabIndex(…) Sets the default selection subscript
setTabBarBadgeValue(…) Sets the message bubble content for a TarBarItem
hideTabBadgeValue(…) Hide a TarBarItem message bubble
setTabBarBadgeValueColor(…) Sets the message bubble color for a TarBarItem
3. The use of YYTabBar
  • Basic Style use

    let chidVC=[CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavControlle r(),CommonWithoutNavController()] let builder:TabBarBasicParamBuilder=TabBarBasicParamBuilder .with(childVCs: chidVC, normalImgs: normalImgs, selectImgs: selectImgs, titles: titles) .defultStyle() .setTextColor(txtColor: UIColor.black) .setSelectTextColor(selectTxtColor: UIColor.red) .setImgColor(imageColor: UIColor.black) .setSelectImgColor(selectImageColor: UIColor.red) .build() let _:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: builder)Copy the code
  • TarBarItem is used in an irregular style

    let chidVC=[CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavControlle r(),CommonWithoutNavController()] let builder:TabBarBasicParamBuilder=TabBarBasicParamBuilder .with(childVCs: chidVC, normalImgs: normalImgs, selectImgs: selectImgs, titles: titles) .defultStyle() .irregularity() .setIrregularityIndex(irregularIndex: 2) .setIrregularityBorderColor(borderColor: UIColor.white) .setIrregularityBackgroundColor(backgroundColor: UIColor.systemGreen) .retunDefaultStyle() .setSelectTextColor(selectTxtColor: UIColor.red) .setSelectImgColor(selectImageColor: UIColor.red) .build() let tab:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: builder) tab.setTabBarBackgroundImage(backgroundImage: UIImage(named: "background_dark")) tab.setShouldHijackHandler(shouldHijackHandler:{ tabBarController,viewController,index in if(index==2){ return true }else{ return false } }) tab.setDidHijackhHandler(didHijackHandler: { tabBarController,viewController,index in })Copy the code
  • Set the background color display (without title)

    let chidVC=[CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavController(),CommonWithoutNavControlle r(),CommonWithoutNavController()] let builder:TabBarBasicParamBuilder=TabBarBasicParamBuilder .with(childVCs: chidVC, normalImgs: normalImgs, selectImgs: selectImgs, titles: Titles). DefultStyle (.) backgroundColorWithoutTitlesAnimationStyle () / / set the background color display (with no title) SetSwithcBouncesAnimation (switchBgAnimation: true) / / open spring animation setSpecialIndexAndColor (bgColorIndex: RetunDefaultStyle ().setreMinduseclickIndex (remindUseClickIndex: Build () let _:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: Builder)Copy the code
  • YYTabBar and YYNavigationBar are used together

Note that if the content ControllerView is set to its original height, the bottom of the TabBar will be blocked. To solve this problem, you need to set two steps
  • The first step Before creating content ControllerView need to calculate the height of the content View (UIViewController. AutoHeight = UIScreen. Main. Bounds. Height – The self. The tabBar. Frame. Height)

      let chidVC: [UIViewController] = titles.map { _ in
          UIViewController.autoHeight=UIScreen.main.bounds.height - self.tabBar.frame.height
          let vc: CommonWithNavController = CommonWithNavController()
          return vc
      }
      
      
      let builder:TabBarBasicParamBuilder=TabBarBasicParamBuilder
          .with(childVCs: chidVC, normalImgs: normalImgs, selectImgs: selectImgs, titles: titles)
          .defultStyle()
          .build()
      
      
      let _:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: builder)
    Copy the code
  • The second step ControllerView need to implement AutoHeightUIViewController content

  • YYTabBar default message bubbles are used

     let tabBar:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: builder)
     tabBar.setTabBarBadgeValue(index: 0, badgeValue: "99+")
     tabBar.setTabBarBadgeValue(index: 1, badgeValue: " ")
     tabBar.setTabBarBadgeValue(index: 2, badgeValue: "")
     tabBar.setTabBarBadgeValue(index: 3, badgeValue: "New")
     tabBar.setTabBarBadgeValue(index:4, badgeValue: "1")
     tabBar.setTabBarBadgeValueColor(index: 4, color: UIColor.blue)
     tabBar.setShouldHijackHandler(shouldHijackHandler: {
         tabBarController,viewController,index in
         
         if(index==2){
             tabBar.hideTabBadgeValue(index: 2)
         }else if(index==4){
             tabBar.setTabBarBadgeValueColor(index: 4, color: UIColor.red)
         }
         return false
     })
    Copy the code
  • YYTabBar User-defined TabBarItemView

1. YYTabBarItemContentView is introduced
attribute role
insets Set the offset of the contentView
selected Selected or not
insets Set the offset of the contentView
highlighted Whether it is highlighted
highlightEnabled Whether highlighting is supported
textColor Text color
highlightTextColor Highlight text color
iconColor Icon color
backdropColor The background color
highlightBackdropColor Highlight background color
title The title
badgeValue Message bubble content
badgeColor Message bubble color
badgeView Get the message bubble View
selectAnimation(animated: Bool, completion: (() -> ())?) Set animation when selecting
reselectAnimation(animated: Bool, completion: (() -> ())?) Set the release animation
highlightAnimation(animated: Bool, completion: (() -> ())?) Set the highlight animation
dehighlightAnimation(animated: Bool, completion: (() -> ())?) Set release highlight animation
badgeChangedAnimation(animated: Bool, completion: (() -> ())?) Sets the message animation to animate when it changes
2. Implement YYTabBarItemContentView and customize related parameters
3. Set a custom TabBarItemView
let cumstonItemView=[CumstonSettingItemView(),CumstonAnimateWithTipsContentView(),CumstonAnimateWithNumContentView(),Cumston AnimateWithImgContentView(),cumstonRemindItemView] let builder:TabBarBasicParamBuilder=TabBarBasicParamBuilder .with(childVCs: chidVC, normalImgs: normalImgs, selectImgs: selectImgs, titles: titles) .cumstomStyle() .setCumstonTabBarItemView(cumstomItemView: cumstonItemView) .build() let tab:TabBarSetting=TabBarSetting(vc:self,tabBarBuilder: builder)Copy the code

7. YYPageView: Picture rotation

  • Create a PageView

      let pageView:YYPageView={
      let pageView:YYPageView=YYPageView.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 300))
      pageView.register(YYDefaltPageViewCell.self, forCellWithReuseIdentifier: "cell")
      pageView.transformer = YYPageViewTransformer(type:.none)
      pageView.pageControl.interitemSpacing=10
      return pageView
      }()
    Copy the code
  • Implement YYPagerViewDataSource YYPagerViewDelegate

    Func numberOfItems(in pagerView: YYPageView) -> Int {return imageNames. Count} func pagerView(_ pagerView: YYPageView, cellForItemAt index: Int) -> UICollectionViewCell { let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index) as! YYDefaltPageViewCell cell.imageView? .image=UIImage(named:imageNames[index] ) cell.imageView? .contentMode = .scaleAspectFill cell.imageView? .clipsToBounds = true cell.textLabel? .text = string.init (format: "%d ", index) return cell}.text = string.init (format:" % D ", index) return cell}Copy the code
  • See Demo for other uses

YYPageMenu: Sliding menu

1. Basic use of YYPageMenu (note below)
let menu = YYPageMenu.init(frame:CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50),vc: self, titles: Titles) / / Settings menu below the NavigationBar PositionSettingUtils. Position (aboveView: self. The navigation bar, childView: menu! , style: the adaptive) / / set the content View PositionSettingUtils under the menu. The position (aboveView: menu! , childView: menu! .page! .view, style: .fixed) self.view.addSubview(menu!) / / in order to solve the problem of shade, need to calculate the height before initialization content View, and the content of the View needs to implement AutoHeightUIViewController let viewControllers: [UIViewController] = self.titles.map { _ in UIViewController.autoHeight=menu! .page! .view.frame.height let vc: ChildPageViewController = ChildPageViewController(pageMenuVc: Self) return vc} // Initialize the content View menu! .page? .initController(viewControllers: viewControllers) var style:YYPageMenuStyle=YYPageMenuStyle() style.indicatorColor = .red style.indicatorCorner = .corner(value: 3) style.indicatorStyle = .line(widthType: .sizeToFit(minWidth: 20), position: .bottom((margin: 1, height: 2))) style.titleFont = UIFont.systemFont(ofSize: 18) style.selectedTitleColor=UIColor.red menu! .style=style menu! .backgroundcolor = uicolor. yellow //menu Select callback menu! .page! .didFinishPagingCallBack={ currentViewController,currentIndex in self.menu! .setSelectIndex(index: currentIndex) }Copy the code
2. Basic attributes of YYPageMenuStyle
attribute role
indicatorColor Indicator color
indicatorStyle Indicator style, type of YYPageMenuIndicatorStyle: horizontal line type, line (widthType: YYPageMenuItemWidthType, position: YYPageMenulinePosition)/ Cover type, cover(widthType: YYPageMenuItemWidthType)
indicatorCorner Indicator fillet
labelWidthType The main types are YYPageMenuItemWidthType: full, Fixed (width: CGFloat)/ adaptive, sizeToFit(minWidth: CGFloat).
titleFont The title font
normalTitleColor normalTitleColor
selectedTitleColor Select the title color
iconColor Icon color
backdropColor The background color
highlightBackdropColor Highlight background color
title The title
badgeValue Message bubble content
badgeColor Message bubble color

YYRefresh: pull down refresh/pull up load more

  • Use the default pull-down refresh/pull-up to load more style

    let refreshView:YYDefaultRefreshHeaderAnimator=YYDefaultRefreshHeaderAnimator.init(frame: .zero) let footView:YYDefaultRefreshFooterAnimator=YYDefaultRefreshFooterAnimator.init(frame: .zero) self.tableView.yy.addPullToRefreshListener(animator: refreshView, handler: { [weak self] in self? .refresh() },aboveView: navigation.bar,childView: self.tableView) self.tableView.yy.addLoadMoreListener(animator: footView){ [weak self] in self? .loadMore() }Copy the code
  • The default controls YYDefaultRefreshHeaderAnimator/YDefaultRefreshFooterAnimator modified tooltip text

attribute role
YYDefaultRefreshHeaderAnimator
pullToRefreshDescription Refresh prompt text
releaseToRefreshDescription Release prompt text
loadingDescription Loading prompt text
YDefaultRefreshFooterAnimator
loadingMoreDescription Pull up to load prompt text
noMoreDataDescription No data prompt text
loadingDescription Loading prompt text
  • Common methods
methods role
addPullToRefreshListener(animator: YYRefreshProtocol & YYRefreshAnimatorProtocol, handler: @escaping YYRefreshHandler,aboveView:UIView,childView:UIView) Add drop-down refresh styles, refresh callbacks, and under a control
addLoadMoreListener(animator: YYRefreshProtocol & YYRefreshAnimatorProtocol, handler: @escaping YYRefreshHandler) Add more style for pull-up loading and refresh callbacks
removeRefreshHeader() Remove the drop-down refresh control
removeRefreshFooter() Remove the pull-up refresh control
startPullToRefresh() Start the drop-down refresh
autoPullToRefresh() Automatic drop-down refresh
stopPullToRefresh() Stop the drop-down refresh
noticeNoMoreData() Notification that there is no data to load
resetNoMoreData() Reset no data
stopLoadingMore() Stop the pull-up load refresh
  • Custom load control to achieve UIView, YYRefreshAnimatorProtocol YYRefreshProtocol can according to the parameters given by the inside of the custom, specific can refer to the demo

YYImageLoader: Network image loading

  • Common methods
methods role
loadImage(urlString: String,placeholder: UIImage? = nil,completion: ((_ success: Bool, _ error: Error?) -> Void)? = nil) Loading network images
loadImage(url: URL, placeholder: UIImage? = nil,completion: ((_ success: Bool, _ error: Error?) -> Void)? = nil) Loading network images
loadImage(request: URLRequest,placeholder: UIImage? = nil,completion: ((_ success: Bool, _ error: Error?) -> Void)? = nil) Loading network images
  • The global method YYImageCache
methods role
diskCacheMaxAge Set the maximum cache time
timeoutIntervalForRequest The request timeout
requestCachePolicy Image loading strategy
  • Basic usage code

     imageView.loadImage(urlString: "https://n.sinaimg.cn/tech/transform/8/w334h474/20200107/57f4-imvsvyz4459804.gif",placeholder: UIImage.init(named: "b"))
    Copy the code

YYDialog: Universal prompt box

  • The default prompt box is used

AlertDialog

YYDialog .createAlertDialog() .defalutDialog() .setTitleColor(color: UIColor.red) .setTitleSize(ofSize: 20) .setContentColor(color: UIColor.gray) .setSubmitBtnSize(ofSize: 20) .setSubmitBtnContentColor(color: UIColor.green) .setAnimationOption(animationOption: .zoom) .setSubmitButtonListener(clickSubmitBlock: {_ in yydialog.createtoast ().show(view: self.view, text: "click ok ")}).setButtonType(btnType:.both).show(title: "Hint ", Message:" Because you are the cleanest, warmest, softest thing in the world, AND I can't explain you, treat you, or put you off with generic wisdom." )Copy the code

Toast

Yydialog.createtoast ().show(view: self.view, text: "Because you are the cleanest, warmest, softest thing in the world, I can't explain you, treat you, or put you off with the universal wisdom." )Copy the code

LoadingDialog

let dialog = YYDialog .createLoadingDialog() .defalutDialog() dialog .setMessageSize(fontSize: 16) .setContentViewCornerRadius(radius: 5) .setMaskLayer(showMaskLayer: true) .setAnimationOption(animationOption: .zoom).show(message: "Please hold..." )Copy the code
  • Customize the prompt box
1. Implement BaseDialogContentView
attribute role
_contentWidth Prompt box width, BaseDialogContentView has been set to default
_contentHeight This parameter is mandatory
animationOption Prompt box animation, BaseDialogContentView set to default
2. Customize the usage method
let dialog=YYDialog
            .createLoadingDialog()
            .customDialog(custom: CustomLoadingDialog())
        
 dialog.show()
Copy the code
  • For other attributes modification, see Demo

Use of DataManager (Http, UserDefaults, File, SQLite)

The properties of DataManager
  • DataForHttp(Http module in DataManager)
attribute role
GlobalSetting(Http global parameter setting module)
showHttpRequestLog Http request logs are generated
cacheTimeOutWithClear Cache expiration time
timeoutIntervalForRequest timeout
HttpOfNormal(basic network request module for Http)
Request<T:Convertible>.request(…) Http generic request method that converts directly to a Bean class that needs to inherit Convertible
Share.cancel(…) Cancel the request
Share.removeAllCache(…) Clear all caches
Share.removeObjectCache(…) Clear the cache by URL and params
HttpOfUpload(Http image upload module)
Upload<T:Convertible>.upload(…) The Http generic upload method converts directly to the Bean class, which needs to inherit Convertible
HttpOfDownload(Http file download module)
Download.download(…) Http generic download method
Download.resume(…) Download initialization is required each time you enter the download page
Download.downloadCancel(…) Cancel the download
Download.downloadCancelAll() Cancel all downloads
Download.downloadPercent(…) Download percentage
Download.downloadDelete(…) Delete a download
Download.downloadStatus(…) Cancel the state
Download.downloadFilePath(…) The location of the file after downloading
  • DataForSQLiteDB(SQLite module in DataManager)
attribute role
QueryData<T:Convertible>.queryAllData() Query all data of the bean class, with T representing the bean type, inheriting Convertible and SQLiteModel
QueryData<T:Convertible>.queryAllDataByAsnyc(…) Asynchronously query all data of the bean class, with T representing the bean type, inheriting Convertible and SQLiteModel
QueryData<T:Convertible>.queryDataByWhere(…) Query data based on SQL criteria
QueryData<T:Convertible>.queryDataWithWhereByAsync(…) Asynchronously query data based on SQL criteria
QueryData<T:Convertible>.queryDataByFirst(…) Querying the first data
Share.insertData(…) Insert data
Share.insertDataList(…) Insert list data
Share.insertDataListByAsync(…) Asynchronously insert list data
Share.deleteDataByWhere(…) Delete data based on SQL conditions
Share.deleteAllData(…) Delete all data
Share.deleteAllDataByAsync(…) Delete all data asynchronously
Share.updateData(…) Update the data
Share.updateDataList(…) Update data list
Share.updateDataListByAsync(…) Update the data list asynchronously
Share.drop(…) Delete table
  • DataForFile(File module in DataManager)
attribute role
saveObjectForFile(…) Save the content of the field, including parameter appendFolderPathAndFileName represents the file path, here only set added path (/ test/test. TXT)
queryObjectForFile(…) Get content by path
  • DataForUserDefaults(UserDefaults module in DataManager)
attribute role
saveObjectForKey(…) Save the content
queryObjectForKey(…) Get content by Key
1.Http
  • Basic network request

    let urlStr = "https://api.apiopen.top/getJoke? page="+String(format: "%1d", pageNow)+"&count=20&type=video" let httpParams:HttpRequestParams=HttpRequestParams() httpParams .setRequestType(requestType: .reqStringUrl) .setReqUrl(requestUrl: urlStr) .setReponseType(responseType: .netWork) .setHttpTypeAndReqParamType(httpTypeAndReqParamType: .get) .build() DataManager.DataForHttp.HttpOfNormal.Request<Result<Array<ContentInfo>>>.request(httpRequestParams: httpParams, requestSuccessResult: { value in }, requestFailureResult: { error in })Copy the code
Note: A generic class needs to be passed in as the conversion data structure for json data at request time, and the bean class needs to implement Convertible to convert
  • HttpRequestParams
attribute role
setReponseType(responseType:ReponseType) Set the response mode. Cache: returns cache data; netWork: returns netWork data; noCacheRetrunNetWork: gives priority to cache
SetHttpTypeAndReqParamType (parameters) Set the request method and request parameter types. Post_json: method is POST, request parameter is JSON format, pos_param: method is POST, request parameter is key-value pair, and get: method is GET
setReqUrl(requestUrl:String) Setting the request Url
setUrlRequest(urlRequest: URLRequestConvertible) Set request URLRequest
setRequestType(requestType:RequestType) Sets the type of request
setParams(params: Parameters) Sets the set of request parameters
setParam(key:String,param:Any) Setting request Parameters
setHttpHeaders(headers: HTTPHeaders) Set the request header list
setHttpHeader(key:String,header:String) Set the request header
  • File download
1. Download initialization is required each time you enter the download page
DataManager.DataForHttp.HttpOfDownload.Download.resume(url: item.downloadUrl, downloadResume: {
        //
 })
Copy the code
2. Download files
let downloadParams:HttpDownloadRequestParams=HttpDownloadRequestParams()
            downloadParams
                .setFileName(fileName: "\(item.indexPath.row)---.pdf")
                .setReqUrl(requestUrl: url!)
                .build()
            
DataManager.DataForHttp.HttpOfDownload.Download.download(httpDownloadRequestParams: downloadParams, requestSuccessResult: {
                respone in
               
            },requestFailureResult: {
                error in
                
            },downloadProgress: {
                progress in
                
            })
Copy the code
  • HttpDownloadRequestParams
attribute role
setFileName(fileName:String) Set the download file name
SetHttpTypeAndReqParamType (parameters) Set the request method and request parameter types. Post_json: method is POST, request parameter is JSON format, pos_param: method is POST, request parameter is key-value pair, and get: method is GET
setReqUrl(requestUrl:String) Setting the request Url
setParams(params: Parameters) Sets the request parameter list
setParam(key:String,param:Any) Setting request Parameters
setHttpHeaders(headers: HTTPHeaders) Set the request header list
setHttpHeader(key:String,header:String) Set the request header
  • Image upload

    let url="xxxxx" let httpParams=HttpUploadRequestParams() httpParams .setParam(key: "type", param: SetParams () can also set array.setrequrl (requestUrl: url) // set request link. SetFileSuffixName (fileSuffixName: .setimages (images: [UIImage(named: "d")!,UIImage(named: "e")!] // Set the list of images to upload. SetMultiparName (multipartName: "ImgList ") // Set the corresponding background server upload file field.build() /** The been class converted by the generic Settings result, Can return to the Upload progress * / DataManager. DataForHttp. HttpOfUpload. Upload. Upload (httpRequestParams: httpParams requestSuccessResult: { result in }, requestFailureResult: { error in }, requestProgress: { progress in })Copy the code
  • HttpUploadRequestParams

attribute role
setMultiparName(multipartName:String) Field name provided by the interface
setImages(images: [UIImage]?) Setting up pictures to upload
setFileSuffixName(fileSuffixName:String) Set the file name extension of the uploaded image
setReqUrl(requestUrl:String) Setting the request URL
setParams(params: Parameters) Setting request Parameters
setParam(key:String,param:Any)- Setting request Parameters
setHttpHeaders(headers: HTTPHeaders)- Set the request header
setHttpHeader(key:String,header:String) Set the request header
2.SQLite(takes a long time when there is a large amount of data)
  • Initialize the database and migrate it

    SQLiteVersionMigrate.setDbVersion(dbName:"collectionDB",dbVersion: 0,migrate: { oldVersion,newVersion in for i in oldVersion... newVersion{ if(i == 1){ SQLiteVersionMigrate .with(cls: SqliteData.self) .addAttribute(attribute: "a1", dataType: String.self) .addAttribute(attribute: "a2", dataType: String.self) .build() } } })Copy the code
Note:
1. Set the database name
2. SQLiteVersionMigrate enables version migration
3.SQLiteVersionMigrate
attribute role
setDbVersion(…) Set the data name, version number, and version change callback
with(…) The Settings require changes to the bean class
addAttribute(…) Fields that need to be added to the table
  • The saved bean class

      @objcMembers
      class SqliteData: SQLiteModel,Convertible{
    
          var des:String=""
          var id:Int=0
    
          override func primaryKey() -> String {
              return "id"
          }
    
      }
    Copy the code
Note: The bean needs:
1. Using the @ objcMembers
2. Implement SQLiteModel
3. Implement Convertible(Json to bean needed)
4. To implement the primaryKey() method, you must specify the primaryKey
  • Instance initialization

    let commonSqliteData=SqliteData() commonSqliteData? .id=0 commonSqliteData? .des="SQLite test use"Copy the code
  • Insert data

      DataManager.DataForSQLiteDB.Share.insertData(object: commonSqliteData!)
    Copy the code
  • Delete all data

      DataManager.DataForSQLiteDB.Share.deleteAllData(cls: SqliteData.self)
    Copy the code
  • Asynchronously insert data

    DataManager.DataForSQLiteDB.Share.insertDataListByAsync(cls: SqliteData.self, objectList: list, insertCompleteBlock: {})Copy the code
  • Update the data

      DataManager.DataForSQLiteDB.Share.updateData(object: commonSqliteData!)
    Copy the code
  • Query data

      let result=DataManager.DataForSQLiteDB.QueryData<SqliteData>.queryAllData()
      DataManager.DataForSQLiteDB.Share.updateData(object: commonSqliteData!)
    Copy the code
  • Others can be viewed at DataManager

3.File
  • Query data

      let result=DataManager.DataForFile<String>.queryObjectForFile(appendFolderPathAndFileName:"test/test.txt")
    Copy the code
  • Save the data

    / / save type String DataManager. DataForFile < String >. SaveObjectForFile (appendFolderPathAndFileName: "the test/test. TXT", the object: "123") / / save the type DataManager. DataForFile < UserDeBean >. SaveObjectForFile (appendFolderPathAndFileName: appendBeanPath, object: userDefault)Copy the code
3.UserDefaults
  • Save the data

      DataManager.DataForUserDefaults<String>.saveObjectForKey(key: "key1", object:"1234")
    Copy the code
  • Query data

      let result=DataManager.DataForUserDefaults<UserDeBean>.queryObjectForKey(key: "key2")
    Copy the code

YYDataShowView: Data loading display page

  • YYDataShowView Basic usage
attribute role
init(defaultDataShowViewParams:DefaultDataShowViewParams,…) Default initialization method
init(custom:BaseDataShowContentView,visibileHeight:CGFloat? =UIScreen.main.bounds.height,aboveView:UIView? =nil)) Custom display content initialization methods
show(parentView:UIViewController) Display DataShowView
hide() Hidden DataShowView
  • DefaultDataShowViewParams basic usage
attribute role
setDefaultDataShowViewType(…) Set display styles: noData, noNetWork, Loading
setDefaultNoDataShowImg(…) Sets the image to display when there is no data
setDefaultNoNetworkShowImg(…) Set no network is displayed for the picture
setDefaultShowImgWidth(…) Sets the width of the image to display
setDefaultShowImgHeight(…) Sets the height of the image to display
setDefaultShowNoDataText(…) Sets the text to display when there is no data
setDefaultShowNoNetWorkText(…) Sets the text to display when there is no network
setDefaultShowTextSize(…) Sets the font size for the displayed text
setDefaultShowTextColor(…) Sets the color of the displayed text
setDefaultShowButtonText(…) Sets the text of the button
setDefaultShowButtonTextSize(…) Sets the font size of the button
setDefaultShowButtonTextColor(…) Sets the text color of the button
setDefaultShowButtonBorderWidth(…) Sets the border width of the button
setDefaultShowButtonBorderColor(…) Sets the button border color
setDefaultSHowButtonPadding(…) Sets the inside margin of the button
setDefaultShowButtonCornerRadius(…) Set the rounded corner of the button
setHiddenShowButton(i…) Sets whether the button is displayed
setDefaultShowButtonBackgroundColor(…) Sets the button background color
setDefaultShowLoadingText(…) Set load text
setDefaulutShowLoadingImgsTimeInterval(…) Set the interval for loading the Image
  • No data style

    let defaultDataShowViewParams=DefaultDataShowViewParams() defaultDataShowViewParams .setDefaultNoDataShowImg(defaultNoDataShowImg: “nodata”) .build() dataShowView=YYDataShowView(defaultDataShowViewParams:defaultDataShowViewParams,aboveView: Navigation bar, reloadHandler: {YYDialog. CreateToast (.) the show (view: the self view, the text: “click the reload button”)})

    dataShowView! .show(parentView: self)

  • No web style

    let defaultDataShowViewParams=DefaultDataShowViewParams() defaultDataShowViewParams .setDefaultDataShowViewType(showViewType: .noNetWork) .setDefaultNoNetworkShowImg(defaultNoNetworkShowImg: “nonetwork”) .build()

    dataShowView=YYDataShowView(defaultDataShowViewParams: defaultDataShowViewParams,aboveView: Navigation bar, reloadHandler: {YYDialog. CreateToast (.) the show (view: the self view, the text: "click the reload button")}) dataShowView! .show(parentView: self)Copy the code
  • Load data style

    let imgs=[“default_data_show_loading1″,”default_data_show_loading2″,”default_data_show_loading3”,”default_data_show_loading4 “,”default_data_show_loading5″,”default_data_show_loading6″,”default_data_show_loading7″,”default_data_show_loading8″,”d efault_data_show_loading10″,”default_data_show_loading11″,”default_data_show_loading12”]

    let defaultDataShowViewParams=DefaultDataShowViewParams() defaultDataShowViewParams .setDefaultDataShowViewType(showViewType: .loading) .setDefaultLoadingImags(defaultLoadingImags: imgs) .build()

    dataShowView=YYDataShowView(defaultDataShowViewParams: defaultDataShowViewParams,aboveView: navigation.bar) dataShowView! .show(parentView: self)

  • Custom styles

1. Implement BaseDataShowContentView and specify _contentHeight(height)
2. Load the custom View
let customView=CustomDataShowView()
YYDataShowView.init(custom: customView,aboveView: navigation.bar).show(parentView: self)
Copy the code

14, YYTagView

  • Basic usage
attribute role
YYTagViewBuilder
setTagTextColor(…) Sets the font color for the Tag
setTagSelectedTextColor(…) Sets the font color for the Tag click
setTagLineBreakMode(…) Set the LineBreakMode for the Tag
setTagBackgroundColor(…) Sets the background color of the Tag
setTagSelectBackgroundColor(…) Sets the background color for Tag selection
setTagCornerRadius(…) Set the rounded corners of the Tag
setTagBorderWidth(…) Set the outer width of the Tag
setTagBorderColor(…) Sets the color of the outer frame of the Tag
setTagSelectedBorderColor(…) Sets the color of the Tag selection
setTagHorizontalPadding(…) Sets the left and right inner margins of the Tag
setTagVerticalPadding(…) Sets the upper and lower inner margins of the Tag
setTagHorizontalMargin(…) Sets the left and right margins of the Tag
setTagVerticalMargin(…) Sets the upper and lower margins of the Tag
setTagAlignment(…) Sets the position of the TagView
setTagShadowColor(…) Sets the shadow color of the Tag
setTagShadowRadius(…) Set the shadow rounded corner of the Tag
setTagTextFont(…) Set the font for the Tag
setTagItem(…) Increase TagItem
setTagItems(…) Set the TagItem list
setTagVerticalMargin(…) Sets the upper and lower margins of the Tag
buildTagView(…) Return TagView
TagView
removeTag(…) Remove TagItem
removeAllTags() Remove TagItems
setTagClick(…) Set the TagItem click event
  • Basic usage code

    Let tags=[" Test use content ","YYTagView","33"," West ","123456"," ijKLMN ","45677","This should be the third Tag "," Human fireworks "] let tags=[" Test use content ","YYTagView","33"," West ","123456"," ijKLMN ","45677","This should be the third Tag "," Human fireworks "] let tagView=YYTagViewBuilder .with() .setTagItems(tags) .setTagTextFont(textFont: UIFont.systemFont(ofSize: 20)) .setTagTextColor(color: UIColor.white) .setTagAlignment(alignment: .center) .setTagBackgroundColor(color: UIColor.systemBlue) .setTagSelectedTextColor(color: UIColor.red) .setTagSelectedBorderColor(color: UIColor.gray) .setTagCornerRadius(cornerRadius: 5) .setTagVerticalPadding(padding: 10) .setTagHorizontalPadding(padding: 10) .setTagVerticalMargin(margin: 10) .setTagHorizontalMargin(margin: 10) .buildTagView() tagView.setTagClick(tagClick: { title,tagView,sender in print(title) })Copy the code

15 and the MVP

Steps:
  • 1. Create a BasePresenter to implement BasePresenter
  • 2. Create a protocol associated with the View
  • 3. Implement the protocol created by IBaseControllerView

    and 2
  • 4. Use mPresenter to call a method in Presenter
  • 5. Call View methods from mView in Presenter
code
  • Agreements and Presenters

    protocol MvpView { func refreshUI(value:Result<Array<ContentInfo>>) } class MvpPresenter:BasePresenter{ func requestData() { let urlStr = "https://api.apiopen.top/getJoke? page=1&count=20&type=video" let httpParams:HttpRequestParams=HttpRequestParams() httpParams .setRequestType(requestType:  .reqStringUrl) .setReqUrl(requestUrl: urlStr) .setReponseType(responseType: .netWork) .setHttpTypeAndReqParamType(httpTypeAndReqParamType: .get) .build() DataManager.DataForHttp.HttpOfNormal.Request<Result<Array<ContentInfo>>>.request(httpRequestParams: httpParams, requestSuccessResult: { value in (self.mView as! MVPUseControllerView).refreshUI(value: value) }, requestFailureResult: { error in }) } }Copy the code
  • The View to achieve

    class MVPUseControllerView:IBaseControllerView<MvpPresenter>,MvpView{ var tableView: UITableView! var manager: YYTableViewManager! var tableViewStyle: UITableView.Style = UITableView.Style.plain let section:YYTableViewSection = YYTableViewSection() var dataLoadingView:YYDataShowView? func refreshUI(value:Result<Array<ContentInfo>>) { for content in value.result! { self.section.add(item: content) } self.manager.reloadData() self.dataLoadingView? .hide() } override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor=UIColor.white self.tableView = UITableView(frame: self.view.bounds, style: self.tableViewStyle) self.view.addSubview(self.tableView); self.manager = YYTableViewManager(tableView: self.tableView) NavigationUtils .with(controller: self) .setBackBarButtonItem(style: .image(UIImage(named: "back_btn")),tintColor: UIColor.gray) .setTitle(title:"MVP") .build() manager.add(section: section) manager.register(ShowCell.self, ContentInfo.self) tableView.separatorStyle = .none let imgs=["default_data_show_loading1","default_data_show_loading2","default_data_show_loading3","default_data_show_loading4 ","default_data_show_loading5","default_data_show_loading6","default_data_show_loading7","default_data_show_loading8","d efault_data_show_loading10","default_data_show_loading11","default_data_show_loading12"] let loadingDataShowViewParams=DefaultDataShowViewParams() loadingDataShowViewParams .setDefaultDataShowViewType(showViewType: .loading) .setDefaultLoadingImags(defaultLoadingImags: imgs) .build() dataLoadingView=YYDataShowView(defaultDataShowViewParams:loadingDataShowViewParams,aboveView:navigation.bar) self.dataLoadingView? .show(parentView: self) mPresenter? .requestData() } }Copy the code

Xvi. General tools

  • IPhoneUtils
attribute role
getNavBarHeight() Get NavigationBar height
isIphoneX() Determine if it is an iphoneX or higher
  • ColorUtils
attribute role
clickSelectBgChange(…) Set the background change when the View is clicked
RGBColor(…) Get RGB color
colorWithHexString() Hexadecimal color is converted to UIColor
  • InternationalUtils
attribute role
getString(…) Gets the local Localizable counterpart
initUserLanguage() Initialization language
setLanguage(…) Setting the current language
getCurrentLanguage() Get the current language
  • UILabelUtils
attribute role
getLabHeigh(…) Gets the UILabel height
  • PositionSettingUtils
attribute role
position(…) Set the position and height of the View
  • Logger(Log output)

  • UILabelPadding(UILabel with inner margin)

attribute role
init(…) Initialize UILabel and set the inner margin

This article will be updated according to the need, suggest to like favorites, easy to view. More suggestions are also welcome.