Searchbar cancel button text is truncated











up vote
1
down vote

favorite












Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit() with no luck.



fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()


enter image description here










share|improve this question






















  • how do you add it to the navigation bar?
    – Scriptable
    Nov 8 at 11:22










  • I'm using navigationItem.titleView = searchController.searchBar
    – Dan
    Nov 8 at 12:02










  • try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
    – Scriptable
    Nov 8 at 12:40

















up vote
1
down vote

favorite












Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit() with no luck.



fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()


enter image description here










share|improve this question






















  • how do you add it to the navigation bar?
    – Scriptable
    Nov 8 at 11:22










  • I'm using navigationItem.titleView = searchController.searchBar
    – Dan
    Nov 8 at 12:02










  • try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
    – Scriptable
    Nov 8 at 12:40















up vote
1
down vote

favorite









up vote
1
down vote

favorite











Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit() with no luck.



fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()


enter image description here










share|improve this question













Having various problems setting up the UISearchBar to work properly. It should be shown in the navigationBar. Using the "old" way setting navigationItem.titleView = searchController.searchBar. As seen on the picture below, the Cancel button text is truncated. Any ideas how to solve this problem? I have tried to set searchController.searchBar.sizeToFit() with no luck.



fileprivate lazy var searchController: UISearchController = {
let sc = UISearchController(searchResultsController: nil)
sc.delegate = self
sc.searchBar.delegate = self
sc.searchBar.returnKeyType = .done
sc.searchBar.tintColor = UIColor.black
sc.searchResultsUpdater = self
sc.hidesNavigationBarDuringPresentation = false
sc.dimsBackgroundDuringPresentation = false
return sc
} ()


enter image description here







swift uisearchbar ios11 uisearchcontroller






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 10:34









Dan

6719




6719












  • how do you add it to the navigation bar?
    – Scriptable
    Nov 8 at 11:22










  • I'm using navigationItem.titleView = searchController.searchBar
    – Dan
    Nov 8 at 12:02










  • try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
    – Scriptable
    Nov 8 at 12:40




















  • how do you add it to the navigation bar?
    – Scriptable
    Nov 8 at 11:22










  • I'm using navigationItem.titleView = searchController.searchBar
    – Dan
    Nov 8 at 12:02










  • try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
    – Scriptable
    Nov 8 at 12:40


















how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22




how do you add it to the navigation bar?
– Scriptable
Nov 8 at 11:22












I'm using navigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02




I'm using navigationItem.titleView = searchController.searchBar
– Dan
Nov 8 at 12:02












try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40






try if #available(iOS 11.0, *) { navigationItem.searchController = searchController } else { navigationItem.titleView = searchController.searchBar searchController.searchBar.sizeToFit() }
– Scriptable
Nov 8 at 12:40



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205927%2fsearchbar-cancel-button-text-is-truncated%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205927%2fsearchbar-cancel-button-text-is-truncated%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff