As I did on Android under a layout arrange an ImageView and TextView and set ClickListener on Layout so same thing how can I do on swift (3.0) Xcode 8
.
There is no markup like XML. It's difficult to do with drag and drop.
How can I make this view with responsive for all device screens.
My UI image is below:
Thanks in advance.
after using CollectionView it shows like this
To make an UIButton's image align to the right side of the text, we force content flipping behavior to the one use it right-to-left language. 1 By adding this semanticContentAttribute = . forceRightToLeft , we force UIKit to mirrored our content which push our image to the right side of the text. Here is the result.
If you want to check If UIButton is Pressed or not, You should handle TouchDown Handler and change button's state to pressed in touchDown hadnler. You can track ToucUpInside method to Change state of button to Not-pressed again.
You can use this code to set image and title to button
let imageSize: CGSize = button.imageView!.image!.size
button.titleEdgeInsets = UIEdgeInsetsMake(26 , -imageSize.width, 0.0, 0.0);
let labelString = NSString(string: button.titleLabel!.text!)
let titleSize = labelString.sizeWithAttributes([NSFontAttributeName: button.titleLabel!.font])
button.imageEdgeInsets = UIEdgeInsetsMake(-15, 0.0, 0.0, -titleSize.width);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With