Display Image with Rounded Corners in iOS App using Swift

Samual Sam
Updated on 30-Jun-2020 05:55:51

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
Updated on 30-Jun-2020 05:50:40

710 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

Extract Last 4 Characters from NSString

karthikeya Boyini
Updated on 30-Jun-2020 05:49:10

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

Send an Attachment in Email Using Swift

Samual Sam
Updated on 30-Jun-2020 05:44:32

626 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

Access RESTful Services from iOS (iPhone)

karthikeya Boyini
Updated on 30-Jun-2020 05:43:40

179 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

Capture Picture from iOS Camera Using Swift

Samual Sam
Updated on 30-Jun-2020 05:35:25

3K+ Views

To capture pictures from a camera in swift we can use AVFoundation which is a framework in iOS SDK, but we should try to avoid using it until we need a lot of custom features in our camera application. In this example, we’ll only capture a picture from the camera and display it on the view. We’ll be using image picker in this example instead of AVFoundation.First, create a project and add an image view on its view Controller in the storyboard. Create the outlet in its class. Now inside the ViewController class conform it to −class ViewController: UIViewController, UIImagePickerControllerDelegate, ... Read More

What are Intent Filters in Android

George John
Updated on 30-Jun-2020 05:29:17

5K+ Views

An intent filter is an instance of the IntentFilter class. Intent filters are helpful while using implicit intents, It is not going to handle in java code, we have to set it up in AndroidManifest.xml. Android must know what kind of intent it is launching so intent filters give the information to android about intent and actions.Before launching intent, android going to do action test, category test and data test. This example demonstrate about how to use intent filters in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required ... Read More

Get Current Time and Date on Android

Ankith Reddy
Updated on 30-Jun-2020 05:28:09

10K+ Views

As per Oracle documentation, SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. In this example, we have imported simple date format class from java as shown below -import java.text.SimpleDateFormat; import java.util.Date;Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have given text view, it going to print the current date on the window manager.Step 3 − Add the following code to ... Read More

Use Images While Developing iOS App in a Simulator

Rishi Rathor
Updated on 30-Jun-2020 05:25:46

2K+ Views

Sometimes we need to test our iOS app with multiple cases and we may not have physical device all the time. For example if we need to see if image upload is working correctly but we do not have an actual iPhone then we may need to add more images to the simulator and test from there. Adding images to simulator is an easy task and can be done in a few different ways. Some of them are mentioned below.Method 1Open Simulator appSelect the image you want to addDrag and drop it in the simulatorIt will be added to the ... Read More

Send Mail from an iPhone Application

Anvi Jain
Updated on 30-Jun-2020 05:25:17

206 Views

To send an email from our application we'll need to use URL Schemes and some action on event of which the email will be sent. We can not actually send email from the application, unless it is an mailing application and we use MessageUI framework of iOS, but we can open some email app from our application with prefilled email and subject.We'll see both the ways of doing this.Let's see how we can open the MAIL app of iOS with an example.Create a project and on its first view controlleradd a button and change it's text to open "open e-mail", ... Read More

Advertisements