Objective:
To create a simple profile with circular profile picture,cover picture and details.
Our desired output has to be like this:
Approach:
1.Create 2 imageviews;
2.Create 3 Labels[studied at:,Lives in,Born on]
Solution:
For the Cover picture-It's very direct,just set the frame to your desired height and create it.
for our profile picture-Create an image view of same width and height and add it is a subview of cover picture.
if we run the program we will not be getting our desired circular profile picture instead it will look like this
But our objective is to make a circular profile picture.so in order to get circular image,we have add layer to the imageview-An instance of CALayer Class [for every view,there is a bundled layer property] & add a corner radius to it.
To make a profile picture circular from a squared one,radius is set to half of the width of UIImageView...Clips to bounds is set to yes to make it work the above statements.if you wish to make it even better try adding border width and corner radius to UIImageView and it will look fabulous.Add 3 labels for showing details and customise the fonts if you like to make it look attractive.
Conclusion:
Thus with right imagination & adding simple lines of codes,we can make a cool circular profile pic.
To create a simple profile with circular profile picture,cover picture and details.
Our desired output has to be like this:
1.Create 2 imageviews;
2.Create 3 Labels[studied at:,Lives in,Born on]
Solution:
For the Cover picture-It's very direct,just set the frame to your desired height and create it.
for our profile picture-Create an image view of same width and height and add it is a subview of cover picture.
if we run the program we will not be getting our desired circular profile picture instead it will look like this
But our objective is to make a circular profile picture.so in order to get circular image,we have add layer to the imageview-An instance of CALayer Class [for every view,there is a bundled layer property] & add a corner radius to it.
To make a profile picture circular from a squared one,radius is set to half of the width of UIImageView...Clips to bounds is set to yes to make it work the above statements.if you wish to make it even better try adding border width and corner radius to UIImageView and it will look fabulous.Add 3 labels for showing details and customise the fonts if you like to make it look attractive.
Conclusion:
Thus with right imagination & adding simple lines of codes,we can make a cool circular profile pic.
No comments:
Post a Comment