iPhone/iPad Articles

Found 85 articles

How Apple designed iPad Pro to act as a Computer

Samual Sam
Samual Sam
Updated on 11-May-2022 189 Views

The new Apple iPad Pro 9.7 was released lately and we can’t wait to get more of it, as it has been in the news for all good reasons. The relationship of Apple with computing devices has been quite complicated, in general. So it was interesting when news spread out that Apple has designed its new iPad Pro in such a way that Apple’s customers will think of it as a computer.Generally if one asks what a computer is, we generally revert to that one-line definition, “Computer is an electronic device with the ability to receive and manipulate data, with ...

Read More

How to remove border in navigationBar in swift?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 2K+ Views

To remove the border from a navigation bar in swift, we just need to add a few lines of code. Let’s see how the navigation bar looks when we run it without changing anything.Now let’s try to hide the line/ border shown in the above result.The navigation bar has two things that give it the default view of a grey shadow along with bottom line as shown above. One is the background image, and the other is the shadow image.First, we’ll hide the shadow image, by setting it to empty image and see how it looks.In your viewDidLoad add the ...

Read More

How to use UICollectionView in Swift?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 594 Views

To use collection view in swift, first, we need to create a collection View. We can either drag and drop it to the storyboard, or we can make it programmatically. After that, we need to confirm our class to UICollectionViewDataSource and UICollectionViewDelegate. Also if we need custom cell size and layouts, we need to confirm it to UICollectionViewDelegateFlowLayout.Let’s see the step required to create a collection View programmatically.func initCollection() {    let layout = UICollectionViewFlowLayout()    layout.itemSize = CGSize(width: 50, height: 50)    let collection = UICollectionView.init(frame: self.view.frame, collectionViewLayout: layout)    collection.dataSource = self    collection.delegate = self    collection.backgroundColor ...

Read More

How to create a Custom Dialog box on iOS App using Swift?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 957 Views

To create a dialog box in swift we’ll make use of UIAlertController which is an important part of UIKit. We’ll do this with help of an iOS application and a sample project.First of all, we’ll create an empty project, then inside its default view controller, we’ll perform the following operations.We’ll create an UIAlertController object.let alert = UIAlertController.init(title: title, message: description, preferredStyle: .alert)We’ll create an actionlet okAction = UIAlertAction.init(title: "Ok", style: .default) { _ in    print("You tapped ok")    //custom action here. }We’ll add the action to the alert and present italert.addAction(okAction) self.present(alert, animated: true, completion: nil)Now we’ll convert this ...

Read More

How to handle right-to-left and left-to-right swipe gestures on iOS App?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 2K+ Views

To handle gestures in iOS application we’ll create an application with swift and see with help of an example. This can be done in two ways, with storyboard or programmatically.Method 1 − With storyboardFirst we’ll drag a swipe gesture recognizer from our object library and drop it in our View controller in which we want to add the swipe gesture.Then click on the gesture, press control and drag in your view controller class to create its connection.Make sure the sender of that action is UISwipeGestureRecognizer and the action looks something like this:@IBAction func swipeMade(_ sender: UISwipeGestureRecognizer) { }Now the swipe ...

Read More

How to display an image with rounded corners on iOS App using Swift?

Samual Sam
Samual Sam
Updated on 30-Jun-2020 3K+ Views

To make an image with round corners or to make any view or button or any UI element with round corners in swift, we need to access the corner radius property of its layer. Every UI element in iOS is based on a layer.First of all, let’s add an UIImageView Object in our storyboard. Or let’s create one programmatically.Below is a function that will programmatically create an image view and add an image to it.func addImage(imageName img: String) {    let imageView = UIImageView()    imageView.frame = CGRect(x: 10, y: 20, width: 200, height: 200)    imageView.contentMode = . scaleAspectFill ...

Read More

Push segue from UITableViewCell to ViewController in Swift

Samual Sam
Samual Sam
Updated on 30-Jun-2020 755 Views

To create a segue from a UITableViewCell to another View controller, we’ll do it like any other ViewController to ViewController segue. We’ll do this with help of an example here.First Create a project, delete the View Controller from storyboard and add One Table View Controller and one View Controller in the storyboard.There will be one prototype cell in the Table View Controller by default. Click on it, go to its attribute inspector and give it “cell” as Identifier.Now from the prototype cell, press control and drag to the Second View Controller and select show from there.The storyboard should look like ...

Read More

How to extract the last 4 characters from NSString?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 1K+ Views

To extract last 4 characters from a string in swift we can use the internal functions of String class in swift.With new release every time methods have been modified, deprecated, added and improved in swift. Swift provides different methods to achieve the same. Let’s see these ways of doing it with a few examples.Method 1 − SubstringsIn swift three we were allowed to use a method called substring in which we could pass the string, it’s last index and the offset from which we wanted to trim the string.Let’s see an example of the same:var Str1 = "12312$$33@" print(Str1.substring(from:Str1.index(Str1.endIndex, offsetBy: ...

Read More

How to send an attachment in email using Swift?

Samual Sam
Samual Sam
Updated on 30-Jun-2020 686 Views

To send an email from our iPhone device using our application we need to import the MessageUI framework of iOS SDK. After importing the framework in your application, drag and drop a button on the view controller. Add empty action for that button.Now add the following code in your view controller.funccomposeEmail(to email: String, subject: String, Body: String) {    if( MFMailComposeViewController.canSendMail()) {       letmailComposer = MFMailComposeViewController()       mailComposer.mailComposeDelegate = self       mailComposer.setToRecipients([email])       mailComposer.setSubject(subject)       mailComposer.setMessageBody(Body, isHTML: true)       letpathPDF = "\(NSTemporaryDirectory())result.pdf"       if let fileData ...

Read More

How to access RESTFul services from iOS/iPhone?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jun-2020 226 Views

To access REST APIs in swift we need to go through a series of steps using the native way of networking in swift, that is using URL sessions and Data Tasks.Rest stands for Representational State Transfer, which defines some set of constraints that are to be used by web services. In swift, we can access web services in the following way.First of all, we need to create a session object, which default configuration.let configuration = URLSessionConfiguration.default let session = URLSession(configuration: configuration)Then we need to create an URL Request of The type we need, it can get, post, delete or put. ...

Read More
Showing 1–10 of 85 articles
« Prev 1 2 3 4 5 9 Next »
Advertisements