Tag:swift

  • What does $0 mean in swiftui and how to use it

    Time:2021-8-18

    $0 represents the first parameter passed to swift closure, which is the syntax sugar of swift language. Swift will automatically provide shorthand parameter names for inline closures. You can use names such as $0, $1, $2 to reference the value of closure parameters. code import UIKit let name = [1,2,3,9,8,6] let reverseName = name.sorted(by:{$0>$1}) let […]

  • Explain in detail what swift clipped is and how to use it

    Time:2021-8-17

    Introduction to clipped() function Clips the view to its bounding rectangular frame. Crop view to rectangle By default, a view’s bounding frame is used only for layout, so any content that extends beyond the edges of the frame is still visible. Use the clipped(antialiased:)modifier to hide any content that extends beyond these edges. By default, […]

  • Swift method for removing unnecessary horizontal lines in empty cells in tableview

    Time:2021-8-16

    in useUITableViewControllerWhen a cell is empty, many horizontal lines will be displayed by default. How to remove it? tofooterHeightJust reverse a minimum value override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 0.001 } result The above is the whole content of this article. I hope it will be helpful to your […]

  • Implementation of IOS swiftui color gradient filling effect

    Time:2021-8-15

    Swiftui provides us with various gradient options, all of which can be used in many ways. Gradient gradient A color gradient represented as an array of color stops, each having a parametric location value. Gradient is the collection of a set of colors, and each color ignores the location parameter LinearGradient linear gradient The linear […]

  • Swift advanced — the use of map and flatmap

    Time:2021-6-16

    Map and flatmap are mainly used in collections and optional types. Let’s look at them respectively. Using map and flatmap on a collection First look at the following code: func getInfos(by name: String) -> [String] { if name == “Jack” { return [“Male”, “25”, “New York”] } else if name == “Lucy” { return [“Female”, […]

  • High order functions commonly used in swift

    Time:2020-12-28

    map var arr = [1, 2, 3] //The map function has a return value. If you want the value map in arr, you need arr to receive a new value in the past arr.map { (a : Int) -> Int in return a * 2 } //This is just a shorthand for trailing closure.. arr […]

  • Examples of various ways to create proxy protocol by IOS swift

    Time:2020-11-27

    preface This article mainly introduces the various ways of creating proxy protocol by IOS swift, and shares them for your reference and study. Let’s not say much below. Let’s have a look at the detailed introduction. If there is a class called lxfview, now we want to create a proxy protocol for this class. What […]

  • IOS swift controller transition animation example code

    Time:2020-9-2

    preface In IOS development, we usually use the default transition animation when we model another controller. This article will give you a detailed introduction to the relevant content of IOS swift controller transition animation, and share it for your reference and learning. Let’s not say much below. Let’s have a look at the detailed introduction. […]

  • Knowledge of swift escape closure in IOS development

    Time:2020-5-6

    Escape closure must meet the following two conditions: 1. The closure is passed to the function as a parameter 2. Closures do not execute until the function returns You need to mark @ escaping in front of the parameter to indicate that the closure allows the function to escape. Note: marking a closure @ escaping […]

  • Five points of developing an IOS music player

    Time:2020-4-13

    It’s easy to play Generally, it is divided into two processes: preparation for playing and playing Prepare to play, including preparing to play resources, player initialization and player preparation Where to play resources var currentAudioPath:URL! currentAudio = readSongNameFromPlist(currentAudioIndex) if let path = Bundle.main.path(forResource: currentAudio, ofType: “mp3”){ currentAudioPath = URL(fileURLWithPath: path) } else{ alertSongExsit() } Player […]

  • Jxtheme: one of the best schemes of ios9 + skin changing / dark mode, lightweight, highly customized, swift writing

    Time:2020-4-11

    brief introduction In 2018, Apple introduced the dark mode in Mac OS system, which was widely praised once launched. Especially for our programmers, they often deal with code and text, and their eyes will be very tired after seeing the bright interface for a long time. With the dark mode, our eyes can finally be […]

  • How to build a vertical tarbarcontroller? Vertical tabbar, generally used for iPad

    Time:2020-4-2

    This kind of demand is not much. If you meet it, you still have to deal with it The idea is container controller, containerviewcontroller Encapsulate a vertical tabbar to manage the controller, There is also a button bar on the left. You can use the table view, uitableview Each button is a cell, and then […]