Custom Reusable Buttons (Swift 5, Xcode 12, 2020) - iOS Development

  Рет қаралды 16,059

iOS Academy

iOS Academy

3 жыл бұрын

In this video we will learn how to create custom reusable buttons in Swift 5 and Xcode 12. We will see how to use view models and the MVVM pattern to configure the button with given state and information. Custom buttons make your app come to life and look great!
💻 Source Code: / iosacademy
🎥 Subscribe for more: kzfaq.info?su...
😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
#swift #customViews #iOSDeveloper
Join this channel to get access to perks, code, groups, and more:
/ @iosacademy
Join the iOS Academy Community: iosacademy.io/
** Get Skillshare free for 2 Months and learn iOS
www.skillshare.com/r/user/afraz
** Manage all your investments from app earnings on Betterment!
bit.ly/3eBwlI9
** Grow your own KZfaq tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy

Пікірлер: 23
@irsyadashari5536
@irsyadashari5536 3 жыл бұрын
Please Whatever you do never stop this channel you have help us alp through the beginner hell of our ios journal development
@albertcampos6581
@albertcampos6581 3 жыл бұрын
Cant wait for it to drop!
@Mitglied99
@Mitglied99 3 жыл бұрын
awesome! thanks a lot from germany :)
@vishweshwaranr2396
@vishweshwaranr2396 3 жыл бұрын
Please put more tutorials on SwiftUI. Your teaching skills are great
@acmcj
@acmcj 3 жыл бұрын
Great video. Would have been great if you'd also shown dynamic type and getting the buttons to respond to dynamic type changes.
@pratikgajbhiye5354
@pratikgajbhiye5354 3 жыл бұрын
Its a personal request to make a video on the horizontal collection view menu at top and can change the view controller in swift .Like instagram have in below the search button once you press
@bolagamal8188
@bolagamal8188 Жыл бұрын
thank you, it is very useful. if anyone is trying to implement this Custom Button, i have a comment on the custom button action not triggered?
@lifeofcoleton
@lifeofcoleton 2 жыл бұрын
How Do You Use this but handle the different states, and change the font weight based on state?
@tg6226
@tg6226 2 жыл бұрын
How do you do this frame.size.width - 5 etc. stuff?? Is there a tutorial re this?
@dewigesrek5651
@dewigesrek5651 2 жыл бұрын
when disabling the translateauto thinggy to add the constraint by our self, the width and height that we set is irrelevant, and we need to add ut again. how do I fix it?
@qCJLbggG4IWAY9nTH6o
@qCJLbggG4IWAY9nTH6o 3 жыл бұрын
This is a great tutorial, I would definitely implement it in my app. One issue I had is that inheritance from UIButton always returns a button with type .custom I'm currently still trying to change it to UIButton.ButtonType.system if anyone fixed this please let me know. One more thing, instead of using a label you could use this: setTitle(viewModel.text, for: .normal) which is also very much customisable.
@qCJLbggG4IWAY9nTH6o
@qCJLbggG4IWAY9nTH6o 3 жыл бұрын
okay so this is my work around: extension UIButton { static func reusableButton(with model: ButtonViewModel) -> UIButton { let button = UIButton(type: .system) button.setTitle(model.text, for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 18) button.setTitleColor(model.titleColour, for: .normal) button.backgroundColor = model.backgroundColour button.layer.cornerRadius = 5 return button } }
@qCJLbggG4IWAY9nTH6o
@qCJLbggG4IWAY9nTH6o 3 жыл бұрын
usage: let button = UIButton.reusableButton(with: ButtonViewModel(text: "Yo!", backgroundColour: .white)) button.frame = CGRect(x: (view.frame.size.width-300)/2, y: 60, width: 300, height: 55) view.addSubview(button)
@APerson-d5s
@APerson-d5s 3 жыл бұрын
Are you finishing the Instagram tutorial?
@ekkogaming5461
@ekkogaming5461 3 жыл бұрын
can we resume the instagram course? it was the best out there ..
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Coming soon
@Sanche87
@Sanche87 Жыл бұрын
didnt work
@iOSAcademy
@iOSAcademy Жыл бұрын
What specifically?
@prettygirl6146
@prettygirl6146 2 жыл бұрын
"ba en"
@shanewhite352
@shanewhite352 3 жыл бұрын
Fuk, how many lines of code needed to write a one button. It should be like, "width, height, rounded corner, colour, text : Align center, Ontap --> do this shiit" simple. It's possible, but language developers make the code more complex to attract programmers, nothing else.
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Quite a few lol
@shanewhite352
@shanewhite352 3 жыл бұрын
@@iOSAcademy Although IDE programmers have pride in writing long codes and do complex things to bring simple click button etc, what they don't realize is they are total shitt as most of the work they do is using interpreted language and real language or machine codes are programmed by real programmers who have written thousands of codes to provide you with those 10 lines of interpreted code. They (the real programmers) can make it simple, but to attract programmers (shitter ones) they make it more complex so you guys can have a self satisfaction. LMAO
@MG-wj4rc
@MG-wj4rc 2 жыл бұрын
@@shanewhite352 I like those who call themselves "real programmers" who do all the dirty work for these "shitter" programmers. You guys would make a 80's style button on a grey background with a blue font in the middle in a few minutes and continue to sit in your cellar writing "real code".
Custom UIViews and UIControls | iOS Swift Checkbox
12:51
Sam Meech-Ward
Рет қаралды 10 М.
New UIKit Button System - iOS 15 - Code & Storyboard
9:51
Sean Allen
Рет қаралды 26 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 195 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 18 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
How to code in Swift | Swift Basics #1
18:25
Swiftful Thinking
Рет қаралды 41 М.
How I learned iOS Development in 30 Days? 0 to Pro!
13:26
Harnoor Singh
Рет қаралды 188 М.
What's going on with Windows Laptops?
10:30
Marques Brownlee
Рет қаралды 2,6 МЛН
SwiftUI: How to make Custom Buttons in 2 different ways | iOS
11:28
How I would start iOS Development in 2024
10:23
Flo writes Code
Рет қаралды 21 М.
Spot The Fake Animal For $10,000
00:40
MrBeast
Рет қаралды 195 МЛН