iOS Articles

Page 10 of 19

How to change background color of TableView items on iOS?

Mohtashim M
Mohtashim M
Updated on 30-Aug-2019 2K+ Views

Changing the background color of table view items is different from changing the background color of the table view. New programmers may often confuse between these two things, In this post, we will be seeing how to change the background color of TableView items i.e. cells.So let’s get started.For changing the background color of the table view cell, you should change the contentView.backgroundColor property of the cell.Add the below code in your cellForRowAt indexPath method, cell.contentView.backgroundColor = UIColor.cyanYour method should look like something below, func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {    let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: ...

Read More

How to create and use Global Variable in swift

Mohtashim M
Mohtashim M
Updated on 30-Aug-2019 3K+ Views

As per the Apple document – “Global variables are variables that are defined outside of any function, method, closure, or type contextBefore we learn how to create global variables, first let us understand completely what are they.Consider “W” which is inside the inner circle, can access everything which will be inside the inner circle. On the other hand, A can access everything which is inside the outer circle as well as everything inside the inner circle, so the scope of “A” is global as he can access both the circles.So a global variable can access everything inside the bigger and ...

Read More

Disable Orientation Change in iOS

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 1K+ Views

There are numerous application which either runs on Portrait mode or in Landscape mode.Restricting the application in one of the mode is important to achieve this.In this post we will see how to restrict the orientation or disable the orientation to one mode.If you want the application to be running only in Portrait mode, Below your viewDidLoad method copy the below line of codeoverride var supportedInterfaceOrientations: UIInterfaceOrientationMask {    get {       return .portrait    } }This will lock the landscape mode for your application. Similarly by replacing .portrait to .landscape will run your application in landscape mode.If ...

Read More

How to get current date and time from internet in iOS?

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 570 Views

Working with date and time can be tricky, I’ve seen new programmers struggling with date and time. In almost all the application you will be required to get the date and multiple operations are dependent on it.Here we will be seeing how to get the current date and time in swift.In this post we will be seeing how to get the current time and UTC time.For getting the UTC time, paste below code in playground.let utcDate = Date() print(utcDate)If you wish to get the time stamp of your location, paste the below code in playground.let dateObj = Date() let datetformatter ...

Read More

How to get the differences between two dates in iOS?

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 587 Views

Getting difference between two dates is easy. You should know how to play between the dates.We will be using DateFormatter class for formatting the dates.Instances of DateFormatter create string representations of  NSDate objects, and convert textual representations of dates and times into  NSDate objects.You can read more about it here https://developer.apple.com/documentation/foundation/dateformatterWe will also be using Calendar structure, apple has provided beautiful documentation of it,  https://developer.apple.com/documentation/foundation/calendarSo let’s get started.Open Xcode, New Playground.Copy the below codeimport UIKit // create object of DateFormatter and Calendar let formatter = DateFormatter() let calendar = Calendar.current // specify the format, formatter.dateFormat = "dd-MM-yyyy" // specify the start ...

Read More

How to use both front and back cameras simultaneously in iOS?

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 332 Views

As of now, there’s no way you can access both front and back cameras simultaneously. As both cameras have different session, as soon as one will start other session will die.As per the apple developer forum answered by Apple support team −“Apps cannot capture from the front and back cameras simultaneously. You can switch from one to the other (with a short delay between) but not both at the same time”

Read More

How do I create a TableView with rounded corners in iOS?

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 2K+ Views

Table View is one of the most important and fundamental part of iOS application, Every iOS developer should be familiar with it.Almost every application you see in App store use table view.Table views on iOS display a single column of vertically scrolling content, divided into rows. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settingsYou can read more about table view here,  https://developer.apple.com/documentation/uikit/uitableviewIn this post we will see ...

Read More

How to detect user pressing HOME key in iOS?

Mohtashim M
Mohtashim M
Updated on 07-Aug-2019 396 Views

It is very important to know when user is pressing home key as it puts the application to background, here we will be seeing how to identify or get a call when user presses home key.In you AppDelegate.swift, there are delegates methods.Open your AppDelegate.swift and in applicationWillResignActive(_ application: UIApplication) and applicationDidEnterBackground(_ application: UIApplication), write print statement and put a breakpoint as shown.Run the application, once the app is launch tap the home button, applicationWillResignActive will be called and then applicationDidEnterBackground.

Read More

How to lock & unlock the iOS device programmatically

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 731 Views

Locking of iOS device cannot be done programmatically without the use of Private API’s. One such private API’s GSEventLockDevice() (private API) from GraphicsServices.framework which might help you achieve your persona but the application would result in rejection from Apple’s App Store.More over there’s no documentation provided by apple for the same.On a final note you cannot achieve this functionality without using the Private API’s and if you are using your application will be rejected by Apple.

Read More

Create circular Progress Bar in iOS

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 3K+ Views

It is very important to know how to create a circular progress bar for iOS developers, almost every application have this.This is mainly used in showing the downloading status, loading status or any other progress related thing.Creating Circular Progress bar may become very tedious for new programmers and they might struggle working with it.There are multiple way one can create circular progress bar. In this post we will be seeing one of the simplest and easiest way to create circular progress bar.So let’s get startedStep 1 − Open Xcode, Single View Application, name it CircularProgress.So we will be creating an ...

Read More
Showing 91–100 of 182 articles
« Prev 1 8 9 10 11 12 19 Next »
Advertisements