segmentedControl problem

Hello everybody, I have an issue with displaying segmentedControl. Should I somehow change the height of it or what could it be?

Here is my MapViewController:

import UIKit
import MapKit

class MapViewController: UIViewController {
    var mapView: MKMapView!
    override func loadView() {
        mapView = MKMapView()
        view = mapView
        let segmentedControl = UISegmentedControl(items: ["Standart", "Hybrid","Satellite"])
        segmentedControl.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.5)
        segmentedControl.selectedSegmentIndex = 0
        segmentedControl.translatesAutoresizingMaskIntoConstraints = false
        let topConstraint = segmentedControl.topAnchor.constraintEqualToAnchor(topLayoutGuide.bottomAnchor, constant: 8)
        let margins = view.layoutMarginsGuide
        let leadingConstraint = segmentedControl.bottomAnchor.constraintEqualToAnchor(margins.leadingAnchor)
        let trailingConstraint = segmentedControl.trailingAnchor.constraintEqualToAnchor(margins.trailingAnchor)
        = true = true = true
    override func viewDidLoad() {
        print("MapViewController loaded its view")

Error here:

You should be constraining the leading edge of the segmentedControl to the leading edge of the margin. When I introduce that error into my code, I see the same thing you do–as well as an error in the console.

Thank you! Now everything’s fine! Couldn’t see at all! :slight_smile: