Created
January 28, 2020 20:39
-
-
Save petrpavlik/384e8cf37ebdde78e30ba4a2bcad447d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// AccessibilityTest | |
// | |
// Created by Petr Pavlik on 28/01/2020. | |
// Copyright © 2020 Petr Pavlik. All rights reserved. | |
// | |
import UIKit | |
class TitleView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
let button = UIButton(type: .system) | |
button.setTitle("Aaaa", for: .normal) | |
let button2 = UIButton(type: .system) | |
button2.setTitle("Bbbb", for: .normal) | |
let stackView = UIStackView(arrangedSubviews: [button, button2]) | |
stackView.translatesAutoresizingMaskIntoConstraints = false | |
addSubview(stackView) | |
stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true | |
stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true | |
stackView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true | |
stackView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
// Voice over ands up reading the title instead of TitleView's content | |
// Setting title to nil fixes this. | |
navigationItem.titleView = TitleView() | |
navigationItem.title = "This should not be read by voice over" | |
} | |
} | |
Author
petrpavlik
commented
Jan 28, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment