# Chapter 37: UISearchBar Auto Layout Constraints

**URL:** <https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873>\
**Category:** iOS Apprentice\
**Created:** [April 18, 2020, 2:21pm UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873 "2020-04-18T14:21:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clarkesm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/clarkesm/32/81494_2.png) [@clarkesm](https://forums.kodeco.com/u/clarkesm)\
**Post date:** [April 18, 2020, 2:21pm UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873/1 "2020-04-18T14:21:24Z")

</div>

I’m trying to set the position of the UISearchBar within the view, but Xcode doesn’t let me set any auto constraints. The image below is what I see when I try to set auto constraints on the UISearchBar. If it’s helpful, I also included my view hierarchy. Any suggestions?

![image](https://files.chunter.kodeco.com/original/3X/3/7/37f38d04b496e078e7f68387e9b0ad3fa80b3832.jpeg)

![image](https://files.chunter.kodeco.com/original/3X/8/b/8b0829d52a24b081d105f0fdd4670f7480ad90c5.png)

---

<div class="post-metadata">

**Author:** ![jvantoor](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jvantoor/32/81494_2.png) [@jvantoor](https://forums.kodeco.com/u/jvantoor)\
**Post date:** [April 21, 2020, 3:21am UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873/2 "2020-04-21T03:21:23Z")

</div>

I have exactly the same issue. Posted this question on this forum yesterday. I didn’t see it was asked before.

---

<div class="post-metadata">

**Author:** ![clarkesm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/clarkesm/32/81494_2.png) [@clarkesm](https://forums.kodeco.com/u/clarkesm)\
**Post date:** [April 21, 2020, 11:04am UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873/3 "2020-04-21T11:04:31Z")

</div>

@jvantoor I was able to solve it. Go to the Size Inspector for the search bar and make sure the  
Layout property in the View section is set to Automatic and not Translates Mask Into Constraints. Once you do this you should be able to set Auto Layout constraints.

![image](https://files.chunter.kodeco.com/original/3X/d/3/d3ec5c707bcc508fe471e4f347d50bbe0a92b928.png)

---

<div class="post-metadata">

**Author:** ![gdelarosa](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gdelarosa/32/109063_2.png) [@gdelarosa](https://forums.kodeco.com/u/gdelarosa)\
**Post date:** [April 30, 2020, 6:06pm UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873/4 "2020-04-30T18:06:32Z")

</div>

Hi @clarkesm, thank you for sharing your solution and glad you were able to solve it!

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [October 2, 2020, 6:21am UTC](https://forums.kodeco.com/t/chapter-37-uisearchbar-auto-layout-constraints/105873/5 "2020-10-02T06:21:28Z")

</div>

Closed on October 2, 2020, 6:21am UTC

This topic was automatically closed after 166 days. New replies are no longer allowed.
