Thanks to visit codestin.com
Credit goes to github.com

Skip to content

XiaHaozheJose/Tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tools

Swifts Tools

Are all the extension, You don't need to import any classes

For example

1. Color
let randomColor = UIColor.randomColor()
let hexColor = UIColor.randomColor("#ffffff")
let rgb = UIColor.red.getRGBWithColor() 
2. String cryption

Tools

Swifts Tools

Are all the extension, You don't need to import any classes

For example

1. Color
let randomColor = UIColor.randomColor()
let hexColor = UIColor.randomColor("#ffffff")
let rgb = UIColor.red.getRGBWithColor() 
2. String cryption
To note here, need to cooperate with OC, we create a OC any file, Xcode will prompt us to generate a bridge - Bridging - the Header file XXX. H, here we need # import < CommonCrypto/CommonCrypto.h>, Command + B compiler through. Complete

Now you can use it easily

let md5 = "password".getMd5()
let sha1 = "password".getSha1()
3. UIImage
let redImage = UIImage.imageWithColor(color: .red)

let customSizeImage = UIImage(named: "image").imageWithNewSize(size: mySize)

let cycleImage = UIImage(named: "image")?.clipToCycle(withBorder: 1, withColor: .red)

4. UIView
"alert like android toast"
view.showToast(withString: "I'm a toast", 1.5, 2.5)

5. NSObject
let cachePath = cacheDir()
        let documentPath = documentDir()
        let tempPath = tempDir()
        
        getDirectoryCache(path) { (size) in
            // get all the file sizes through the path
        }
        
        cleanFolder(path) { (completed) in
            // remove all files by the path
        }
6. UIControl
"Refresh For TableView , CollectionView O ScrollView"
 let refresh = JSRefreshControl()
 tableView.addSubview(refresh)
refresh.addTarget(self, action: #selector(your function), for: .valueChanged)

"now you can to refresh"
refresh.beginRefreshing()
refresh.endRefreshing()

7. Download Lib
"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" for test
JSDownLoadManager.shareInstance.downLoadWithInfo(urlName: url, statusType: { (status: JSDownLoadState) in
      //
    }, progresesType: { (progress) in
      //
    }, totalSize: { (fileSize) in
      //
    }) { (filePath) in
      //
    }
    
    // JSDownLoadManager.shareInstance.resumeWithURL(url: url)
    // JSDownLoadManager.shareInstance.pauseWithURL(url: url!)
    // JSDownLoadManager.shareInstance.cancelWithURL(url: url!)
    // JSDownLoadManager.shareInstance.cancelAndCleanWithURl(url: url!)
    // JSDownLoadManager.shareInstance.cancelAll()


8. More Extension
There will be more, if i have time

About

Swifts Tools

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published