小编Max*_*Max的帖子

如何在iOS中从左到右呈现视图控制器?

将新控制器添加到导航堆栈时:

self.navigationController!.pushViewController(PushedViewController(), animated: true)
Run Code Online (Sandbox Code Playgroud)

从右边看:

在此输入图像描述

如何更改动画的方向以使其从左侧显示?

animation uinavigationcontroller ios swift

12
推荐指数
2
解决办法
7349
查看次数

在UlCollectionView中左对齐

如何使UlCollectionView的项目位于行内左侧

在此输入图像描述

这种位置(上方屏幕截图)只能在线路上有唯一项目的情况下进行; 如果线上有多个元素(项目较小或屏幕较宽),则元素在行内左对齐并且位置看起来像所需:

在此输入图像描述

UICollectionViewFlowLayout的设置如下:

UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];

flowLayout.minimumLineSpacing = 20.;
flowLayout.minimumInteritemSpacing = 5.;
flowLayout.sectionInset = UIEdgeInsetsMake(23., 15., 23., 15.);
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;

self.collectionView.collectionViewLayout = flowLayout;
Run Code Online (Sandbox Code Playgroud)

uicollectionview ios8

6
推荐指数
0
解决办法
375
查看次数

如何更改UISearchController中文本字段的背景颜色?

如何在UISearchController搜索文本字段中更改默认灰色背景?

屏幕截图

屏幕截图

ios swift uisearchcontroller ios11

6
推荐指数
2
解决办法
2948
查看次数

在iOS10 +中完成播放后,如何从锁定屏幕上消失播放器控件?

在后台模式下播放音频时,播放器控件会出现在锁屏上。音频停止后如何将其删除?如果尝试设置:

MPNowPlayingInfoCenter.default().nowPlayingInfo = nil
Run Code Online (Sandbox Code Playgroud)

播放器仍在锁定屏幕上,但歌手/歌手字段为空

在此处输入图片说明

UPD(我的音频会话代码):

在AppDelegate中:

func setupAudioSession() {

    let audioSession = AVAudioSession.sharedInstance()

    do {
        try audioSession.setCategory(AVAudioSessionCategoryPlayback)
        try audioSession.setActive(true)

    } catch {
        print("Setting category to AVAudioSessionCategoryPlayback failed.")
    }
}
Run Code Online (Sandbox Code Playgroud)

在播放器类中:

private func clearRemotePlayerInfo() { // call after stop button pressed
    try? AVAudioSession.sharedInstance().setActive(false)
    MPNowPlayingInfoCenter.default().nowPlayingInfo = [:]
}
Run Code Online (Sandbox Code Playgroud)

ios avaudiosession background-audio swift

2
推荐指数
1
解决办法
491
查看次数

如何使用preferredsLargeTitles更改标题注册表?

我知道可以使用分别为«大»和«小»标题设置字体系列,字体大小和颜色prefersLargeTitles

问题是:导航控制器是否有任何选项可以在打开的带有大写字母的导航面板中显示“大标题”?

在此处输入图片说明

现在,我使用自定义导航控制器:

class MyNavigationController: UINavigationController {

    public var titleSaved: String?

    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()

        guard let topItem = navigationBar.topItem else {
            return
        }

        if navigationBar.frame.size.height > 60 {
            topItem.title = topItem.title?.uppercased()
        } else {
            if let titleSaved = titleSaved {
                topItem.title = titleSaved
            } else {
                topItem.title = topItem.title?.applyingTransform(StringTransform(rawValue: "Title"), reverse: false)
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

从视图控件设置标题:

class MyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationController?.navigationBar.prefersLargeTitles = true

        let title = "Sign In"
        navigationItem.title = …
Run Code Online (Sandbox Code Playgroud)

uinavigationbar swift ios11

2
推荐指数
1
解决办法
179
查看次数