如何更改UIImagePickerController导航栏字体?

时间:2016-03-06 18:12:45

标签: ios swift uinavigationcontroller uiimagepickercontroller

我需要它成为Helvetica Neue Light。以下是我创建控制器的方法

let picker: UIImagePickerController = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = false
picker.navigationBar.tintColor = UIColor.whiteColor()
picker.sourceType = .PhotoLibrary
picker.navigationController?.navigationBar.tintColor = UIColor.blueColor()

self.presentViewController(picker, animated: true, completion: { _ in })

1 个答案:

答案 0 :(得分:2)

您就是这样做的:

#pragma once
#ifdef _DEBUG
    //#include <vld.h> /* Visual Leak Detector Memory Leak Detection*/
    #include <crtdbg.h> /*VS Memory Leak Detection*/
    #include <stack>
    #include <memory>
    #include <sstream>
    #include "Windows.h"

class MemoryLeakDetector {
public:
    MemoryLeakDetector() {};
    _CrtMemState MEMORYLEAKSTATISTICS1;
    _CrtMemState MEMORYLEAKSTATISTICS2;
    _CrtMemState MEMORYLEAKSTATISTICS3;
    static std::stack<std::unique_ptr<MemoryLeakDetector>>& stack() {
        static std::stack<std::unique_ptr<MemoryLeakDetector>> s;
        return s;
    }
};


#define DBOUT( s )                              \
do{                                         \
   std::ostringstream os;                   \
   os << s;                                 \
   OutputDebugString(os.str().c_str() );    \
}while(0)

#define BEGINMEMORYLEAKCHECK() do{std::unique_ptr<MemoryLeakDetector> ___memoryleakdetector___ = std::make_unique<MemoryLeakDetector>();\
                                MemoryLeakDetector::stack().push(std::move(___memoryleakdetector___));\
                                _CrtMemCheckpoint(&MemoryLeakDetector::stack().top().get()->MEMORYLEAKSTATISTICS1);\
                                }while(0)           
#define ENDMEMORYLEAKCHECK() do{if(MemoryLeakDetector::stack().size()==0){DBOUT("\n"<<__FILE__<<"("<<__LINE__<<"):"<<"<"<<__FUNCTION__<<" ENDMEMORYLEAKCHECK without BEGINMEMORYLEAKCHECK detected\n");\
                            break;}\
                            std::unique_ptr<MemoryLeakDetector> ___memoryleakdetector___ = std::move(MemoryLeakDetector::stack().top());MemoryLeakDetector::stack().pop();\
                            _CrtMemCheckpoint(&___memoryleakdetector___->MEMORYLEAKSTATISTICS2);\
                            if (_CrtMemDifference(&___memoryleakdetector___->MEMORYLEAKSTATISTICS3, &___memoryleakdetector___->MEMORYLEAKSTATISTICS1, &___memoryleakdetector___->MEMORYLEAKSTATISTICS2)){\
                            DBOUT("\n"<<__FILE__<<"("<<__LINE__<<"):"<<"<"<<__FUNCTION__<<"> MLD detected a leak\n");\
                            _CrtMemDumpStatistics(&___memoryleakdetector___->MEMORYLEAKSTATISTICS3);\
                            DBOUT("\n\n");\
                            std::cerr << "MLD Leak detected "<<__FILE__<<"("<<__LINE__<<")"<< std::endl;\
                            }}while(0)
#else
    #define BEGINMEMORYLEAKCHECK() do{}while(0)
    #define ENDMEMORYLEAKCHECK() do{}while(0)
    #define DBOUT( s )  do{}while(0)
#endif

此外,代码中的一个小问题:picker.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.redColor(), NSFontAttributeName: UIFont.init(name: "Helvetica", size: 21)!] 派生自UIImagePickerControllerUINavigationController始终位于上方代码中picker.navigationController?