So welcome back.
We use IAB design on IB inspectable to essentially be able to change just stuff in the Interface Builder.
Imagine you're designing something and you want to be able to on the fly in the Interface Builder C
for instance the vote of the board there of a view or do you want to see the shadowing the things that
are there in the CIA layer but you cannot see them by default inside sitings Interface Builder.
So if we use IB design around I've been a spectacle to manage that kind of attributes and even though
the names are quite mouthfull they're very very simple to use.
So let me show you views then I'm when I go to Mexico.
I'm going to make a new app called in.
I'd be design if I spelt it right.
If not forgive me for that.
So you're in the view controller.
I want to go ahead and say I have a class on but I call this one custom view just like I've done several
times already and this is a view that we can essentially make any object you know restorable to be a
member of that.
So I could go to my main storyboard
say I have a eye view and this you might view my cyborg.
I'm going to go ahead and say it's actually placed in here are the placement of it cannot be controlled
by an inspector.
So I'm going to put it there myself.
I'm going to say it is of a type of custom.
Now what we want to happen is this we want to be able to change some attributes of a layer which is
not by default accessible in the interface when they're in the Interface Builder.
So in this story with somebody going here say my class is actually of the type I'd design.
Which means it can accept things that are in the layer and the moment you make the design of that you
can actually override the function called prepare for Interface Builder.
Which means now we can have or Leja stuff in here so you could say.
So if DOD background color lets make it you I color dot the light GUI for instance.
So just go ahead and see if this one single attribute is viewable there.
The moment they go to this story is going to show me up there that he is calculating something is building
the interface in there find the storyboard find I it shows me that change that I have made in the IB
design event that I'm going to go by here.
I'm going to do something a little bit more complex and when I a self that layer dot corner radius make
it on a ten point zero.
So you go back to a story about and again is going to Shoney's up there that is calculating it.
So now we can see a little corner radius happening around the corners of my view.
It's a view controller.
And I'm going to say Give me a self dot layer dot border color.
Say it is your eye color red color dot C.G. color of course.
And then I'm going to go ahead and say Give me a border Vitt so layer dot for the vet and I'm going
to play that Tanni.
And if you go back to sleep mode we should be able to see a red.
The border with a bit of tan on here.
Now this is all good and.
But wouldn't it be nice if we had a way of actually changing these values here in Interface Builder
and that is something that we can do and to do that on when they go in here and say within the body
of this class.
And remember we haven't done anything in our view control that we're not going to do anything.
So everything here is happening in a in a custom class.
So within the body of this custom we cannot say I'm going to say I have a variable let's call it was
there a vet and that's going to be a CGI float because it has to be.
And I'm going to say the value was 10 so 10.
I don't need that one anymore.
Somewhat elite that and the border with a meeting here is not going to be accessible in Interface Builder
unless I make it something that we call IAB inspectable.
So let's go in here and say that I'd be in this pic about if I properly spell it I be in this text but
yes I'm going I say at IAB inspectable and then get going here and say within the closure of this this
property I'm going to go ahead and say did this said if we change the value here is what we want to
happen.
We want to say self that layer that border it become bored of it or maybe I should change this name
or we could keep it because I don't like to use exactly the same names for my properties and my tribute
spot and my variables.
But in this case it's OK.
So what happens is this you have a valuable that is being inspected but it means it can be inspected
inside the interface builder.
That's what IBM stands for.
And every time it gets set it has to do something.
What does it do.
It sets the border right.
So let's see that in action.
If you go to sort.
Now I have a board they have it in there.
I'm going to go ahead and say Make it 10 and makes it 10.
And when I say make it 30 and makes it 30.
So that's a quick introduction to how to use I mean respectable values as well as IB is involved as
you can obviously apply any of these routine and even the spectacle and change them up based on you
know based on the value that you produce in the storyboard for instance they could copy this whole thing.
Place it in here and say this is actually corner radius all our radius and the value of it is 10 by
default.
And every time we change it we get to see the corner radius to become the new corner.
And in this storyboard I could actually work with data and immediately change it say.
This one becomes 50 and immediately we see a corner radius of 50.
So this is a very good way for you if you want to design your own custom outlets if you want to have
an office that they have more than the normal settings on properties you could simply apply them by
either redesign or even be a little bit careful in how many of them you use.
In my experience at the moment it becomes a little bit heavy as it starts crashing quite often.
But a lot of times it actually helps us have a better visual feedback of what we're doing.
So with that in mind let's move on to our next lesson.