SwiftyBase
SwiftyBase - A Swift library for Create Project in iOS ( Base Project)
Install / Use
/learn @mspvirajpatel/SwiftyBaseREADME
SwiftyBase
SwiftyBase makes it easy to deal with new Project create in Swift.
- Why use the SwiftyBase
- Requirements
- Integration
- Usage
- Initialization
- BaseViewController
- BaseView
- BaseNavigationController
- BaseImageView
- BaseButton
- BaseProgressHUD
- BaseRoundMenu
- BaseLabel
- BaseTextField
- SideMenu
- AppImageUploadManager
- AppPlistManger
- AppPreferencesExplorer
- AppEventBus
- BaseScrollView
- BaseSegment
- BasePopOverMenu
- BaseNotificationBadge
- AppLocationManager
- In Progress
- Author
Why use the SwiftyBase?
- In software development we all know that we have to reuse code as per as requirement so we have to utilise our code with less effort I will show you one demo on that first make one viewcontroller of baseviewcontroller then make one view of base view initialize this view in controller we can use this view in another controller too ...that’s the main purpose of baseview In storyboard or in one view controller have its own view..We all know that if we have work in owns view, then it will not use for another controller so we can implement on baseview & use it another times with simple initialize.
In Base Project included:
- BaseViewController.swift
- BaseView.swift
- BaseNavigationController.swift
- SideMenu
Extensions :
- Data
- Date
- Dictionary
- NSArray
- NSDictionary
- UIColor
- UINavigationController
- UIScrollView
- UITableView
- UITextField
- UIViewController
- UIFont
- UIView
- String
- UIImage
Utilities:
- AppBaseLayout
- AppConstants
- AppUtility
- AppInterFaceUtility
- AppLocationManager
- AppTimer
- AppAlert
- AppPreferencesExplorer
- AppPlistManger
- AppImageUploadManager
- AppEventBus
Controls:
- BaseImageView - with set Url image with catch support & Clear Catch
- BaseButton - Multiple Button with single class access
- Full screen Image Viewer (ImageViewer)
- BaseRoundMenu
- BaseProgressHUD - Like MBProgressView
- BaseLabel - Multiple BaseLabel with single class access
- BaseTextField - Multiple Textfield with single class access
- BaseScrollView
- BaseSegment
- BasePopOverMenu
- BaseNotificationBadge
Requirements
- iOS 9.0+
- Xcode 8
Integration
CocoaPods (iOS 9)
You can use CocoaPods to install SwiftyBaseby adding it to your Podfile:
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
pod 'SwiftyBase'
end
Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 9.0:
Carthage (iOS 9+)
You can use Carthage to install SwiftyBase by adding it to your Cartfile:
github "mspvirajpatel/SwiftyBase"
Manually (iOS 9+)
To use this library in your project manually you may:
- Just drag ‘SwiftyBase/’ to the project tree
Usage
Initialization
import SwiftyBase
BaseViewController
//If Create ViewContoller using BaseViewController
class ListController: BaseViewController {
// MARK: - Attributes -
// MARK: - Lifecycle -
init() {
}
}
BaseView
//If Create ListView using BaseView
class ListView: BaseView{
// MARK: - Attributes -
// MARK: - Lifecycle -
override init(frame: CGRect) {
super.init(frame:frame)
}
}
BaseNavigationController
//using BaseNavigationController
let listview : ListController = ListController()
let baseNavigation : BaseNavigationController = BaseNavigationController(rootViewController: listview)
BaseImageView
//using BaseImageView for set Image Local or Remote URL
let imgView : BaseImageView = BaseImageView(type: .profile, superView: self)
imgView.layer.setValue("imgView", forKey: ControlConstant.name)
//Set Remote URL for Download and set in Image View
imgView.setImageURL("Enter Your URL")
//For Full Screen Image Show on tap on Image
imgView.setupForImageViewer()
BaseButton
//using BaseButton for set Button with case primary, secondary, radio, rounded Close, close, checkbox, dropdown, transparent
let btnPrimary : BaseButton = BaseButton.init(ibuttonType: .primary, iSuperView: self)
btnPrimary.layer.setValue("btnPrimary", forKey: ControlConstant.name)
btnPrimary.setTitle("Primary Button", for: UIControlState())
let btnSecondary : BaseButton = BaseButton.init(ibuttonType: .secondary, iSuperView: self)
btnSecondary.layer.setValue("btnSecondary", forKey: ControlConstant.name)
btnSecondary.setTitle("Secondary Button", for: UIControlState())
BaseProgressHUD
//Just the loader
BaseProgressHUD.shared.showInView(view: view)
// Add title and footer text
BaseProgressHUD.shared.showInView(view: view, withHeader: "Loading", andFooter: "Please wait...")
// Set color to the header, footer, loader or to the background view
BaseProgressHUD.setHeaderColor(color: UIColor.blue)
BaseProgressHUD.setFooterColor(color: UIColor.blue)
BaseProgressHUD.setLoaderColor(color: UIColor.blue)
BaseProgressHUD.setBackgroundColor(color: UIColor.white)
// Customize: Set color the the background view and let header, footer and loader infer a contrast color
BaseProgressHUD.setBackgroundColor(color: UIColor.white, automaticTextColor: true)
// Or show in a window
BaseProgressHUD.shared.showInWindow(window: window, withHeader: "Loading", andFooter: "Please wait...")
// Hide the HUD
BaseProgressHUD.shared.hide()
// Check if HUD is already being displayed
if BaseProgressHUD.shared.isActive {
print("Currently showing HUD")
} else {
print("HUD is currently hidden")
}
BaseRoundMenu
//using BaseRoundMenu for set Button with case center,topLeft,topRight,bottomLeft,bottomRight
let btncenter = BaseRoundMenu(withPosition: .center, size: 50.0, numberOfPetals: 10, images:[])
let btntopLeft = BaseRoundMenu(withPosition: .topLeft, size: 50.0, numberOfPetals: 4, images:[])
let btntopRight = BaseRoundMenu(withPosition: .topRight, size: 50.0, numberOfPetals: 4, images:[])
let btnbottomLeft = BaseRoundMenu(withPosition: .bottomLeft, size: 50.0, numberOfPetals: 4, images:[])
let btnbottomRight = BaseRoundMenu(withPosition: .bottomRight, size: 50.0, numberOfPetals: 4, images:[])
self.view.addSubview(btncenter)
self.view.addSubview(btntopLeft)
self.view.addSubview(btntopRight)
self.view.addSubview(btnbottomLeft)
self.view.addSubview(btnbottomRight)
btncenter = { (indexSelected) in
debugPrint("Selected Index: \(indexSelected)")
}
BaseLabel
//using BaseLabel for set diffrent types of Buttons
let lblUserName : BaseLabel = BaseLabel(labelType: .small, superView: self)
let lblUserRealName = BaseLabel(labelType: .large, superView: self)
BaseTextField
//using BaseTextField for set diffrent types of BaseTextField like Password, Email
let baseTextField : BaseTextField = BaseTextField.init(iSuperView: self, TextFieldType: .primary)
let baseTextField : BaseTextField = BaseTextField.init(iSuperView: self, TextFieldType: .showPassword)
let baseTextField : BaseTextField = BaseTextField.init(iSuperView: self, TextFieldType: .withoutClear)
let baseTextField : BaseTextField = BaseTextField.init(iSuperView: self, TextFieldType: .noAutoScroll)
SideMenu
//using SideMenu for set Application Menu SideMenu
//SideMenu is a simple and versatile side menu control
let menuLeftNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
menuLeftNavigationController.leftSide = true
// UISideMenuNavigationController is a subclass of UINavigationController, so do any additional configuration
// of it here like setting its viewControllers. If you're using storyboards, you'll want to do something like:
// let menuLeftNavigationController = storyboard!.instantiateViewController(withIdentifier: "LeftMenuNavigationController") as! UISideMenuNavigationController
SideMenuManager.menuLeftNavigationController = menuLeftNavigationController
let menuRightNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
// UISideMenuNavigationController is a subclass of UINavigationController, s
