小编Lex*_*ugh的帖子

为什么 UIButton.setTitle 会改变字体大小?

我正在为课程构建一个 iOS 应用程序,并且正在按照一些说明进行操作。“编辑”按钮连接到toggleEditingMode,但是当我更改文本时,由于某种原因,字体大小被重置为 17,即使在故事板编辑器中它是 30。

我尝试过更改字体大小,如果我在执行 setTitle 后打印当前字体大小,它仍然显示 30,所以看起来它一定发生在 setTitle 之外,但只有在我使用 setTitle 时才会触发。帮助!

class ItemsViewController: UITableViewController {
    var choreStore: ChoreStore!
    var roommateStore: RoommateStore!
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return choreStore.allChores.count
    }
        
    override func tableView(_ tableView: UITableView,
            cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // Create an instance of UITableViewCell with default appearance
        let cell = tableView.dequeueReusableCell(withIdentifier: "chore", for: indexPath) as! ChoreCell

        // Set the text on the cell with the description of the item
        // …
Run Code Online (Sandbox Code Playgroud)

ios swift

15
推荐指数
1
解决办法
5725
查看次数

标签 统计

ios ×1

swift ×1