There are several steps to set up a passcode (passcode) on an iPhone. But if you read on, it will be much easier.
Steps

Step 1. Open "Settings"

Step 2. Tap "General"

Step 3. Go down and click on "Password Protection"

Step 4. Click on "Enable Password"

Step 5. Enter the password of your choice

Step 6. Under Require password, set how often you want the phone to ask for a password
If you select Immediate, your phone will be locked every time you turn off the display. However, if you set a certain length of time, your phone will ask for a password after a certain amount of time, after the last use.
Advice
- Another option is that all your data will be deleted if the access code is entered incorrectly 10 times. This will protect you from someone stealing your phone and trying all 10,000 combinations before entering the correct one.
- Always choose a password that no one knows, in case your phone gets stolen or lost.
- You have the option to choose whether to require a password when you turn off your phone. The default is Immediate, which is the safest option. You can also set it to 15 minutes, 1 hour, and other times.