Posts

Create Segment Control in SwiftUI

SwiftUI’s  Picker  can also be used to create segmented controls equivalent to  UISegmentedControl  from UIKit, although it needs to be bound to some state and you must ensure to give each segment a tag so it can be identified. Segments can be text or pictures; anything else will silently fail. As an example, this creates a segmented control that works with a  favoriteNumber  state property, and adds a text view below that shows whichever value was selected: import SwiftUI struct ContentView : View {     @ State private var favoriteNumber = 0     var numbers = [ "One" , "Two" , "Three" ]          init () {         UISegmentedControl . appearance (). selectedSegmentTintColor = . red         UISegmentedControl . appearance (). setTitleTextAttributes ([. foregroundColor : UIColor . white ], for: . selected )         UISegmentedControl . appearance (). setTitleTextAttributes ([. foregroundColor : UIColor . gray ], for: . normal )     }     var body

Add TabView in SwiftUI

PayUMoney Integration in Swift 5

Step 1:   Add Podfile in your project and inside Podfile , pod 'PayUmoney_PnP' Step 2: Import Framework in your View Controller where you want to use. import PlugNPlay import CommonCrypto Step 3: Call below function inside View Controller.      func continueWithCardPayment ( ) {                  let paymentParam = PUMTxnParam ()         paymentParam. key = "asdas" // change here for merchant key         paymentParam. merchantid = "123324" // Change merchant id         paymentParam. txnID = "12 "         paymentParam. phone = " " // add mobile number here         paymentParam. amount = " 20 " // change amount here         paymentParam. productInfo = ""         paymentParam. surl = "https://www.payumoney.com/mobileapp/payumoney/success.php"         paymentParam. furl = "https://www.payumoney.com/mobileapp/payumoney/failure.php"         paymentParam. firstname = " Dilip "      

Migrating from UIKit to SwiftUI

Here’s a list to get you started, with UIKit class names followed by SwiftUI names: UITableView :  List UICollectionView : No SwiftUI equivalent UILabel :  Text UITextField :  TextField UITextField  with  isSecureTextEntry  set to true:  SecureField UITextView : No SwiftUI equivalent UISwitch :  Toggle UISlider :  Slider UIButton :  Button UINavigationController :  NavigationView UIAlertController  with style  .alert :  Alert UIAlertController  with style  .actionSheet :  ActionSheet UIStackView  with horizontal axis:  HStack UIStackView  with vertical axis:  VStack UIImageView :  Image UISegmentedControl :  SegmentedControl UIStepper :  Stepper UIDatePicker :  DatePicker NSAttributedString : Incompatible with SwiftUI; use  Text  instead. There are many other components that are exclusive to SwiftUI, such as a stack view that lets us build things by depth rather than horizontally or vertically.

What is array in Swift iOS?

Array :-   An array stores multiple values of the same type in an ordered list.  Arrays are one of the most commonly used data types in an app.