# StoreSearch: confused by use of CGRect.zero

**URL:** <https://forums.kodeco.com/t/storesearch-confused-by-use-of-cgrect-zero/14950>\
**Category:** iOS Apprentice\
**Created:** [May 17, 2016, 11:11pm UTC](https://forums.kodeco.com/t/storesearch-confused-by-use-of-cgrect-zero/14950 "2016-05-17T23:11:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krskrft](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/krskrft/32/32701_2.png) [@krskrft](https://forums.kodeco.com/u/krskrft)\
**Post date:** [May 17, 2016, 11:11pm UTC](https://forums.kodeco.com/t/storesearch-confused-by-use-of-cgrect-zero/14950/1 "2016-05-17T23:11:33Z")

</div>

On page 45, we override `awakeFromNib()` in the `SearchResultCell` class in order to customize the cell selection color:

```
override func awakeFromNib() {
    super.awakeFromNib()

    let selectedView = UIView(frame: CGRect.zero)
    selectedView.backgroundColor = UIColor(red: 20/255, green: 160/255, blue: 160/255, alpha: 0.5)
    selectedBackgroundView = selectedView
}

```

What I find confusing is the use of `CGRect.zero`, which seems to indicate that we’re creating a UIView with a size of zero, located at the (0, 0) coordinate within its superview. How is it that this new view covers the entire cell, then? Is this something that the `selectedBackgroundView` property handles on its own?

---

<div class="post-metadata">

**Author:** ![hollance](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/hollance/32/109009_2.png) [@hollance](https://forums.kodeco.com/u/hollance)\
**Post date:** [May 18, 2016, 8:23am UTC](https://forums.kodeco.com/t/storesearch-confused-by-use-of-cgrect-zero/14950/2 "2016-05-18T08:23:39Z")

</div>

Correct. You’re making a view with a size of 0x0. The UITableViewCell itself will take care of resizing it so that it is the same size as the cell. It’s a bit of magic that goes on behind the scenes.

---

<div class="post-metadata">

**Author:** ![krskrft](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/krskrft/32/32701_2.png) [@krskrft](https://forums.kodeco.com/u/krskrft)\
**Post date:** [May 18, 2016, 3:33pm UTC](https://forums.kodeco.com/t/storesearch-confused-by-use-of-cgrect-zero/14950/3 "2016-05-18T15:33:31Z")

</div>

I sort of figured as much, but it had always puzzled me nevertheless. Thanks for the confirmation.
