从UIViewController更改UIWindow backgroundColor?

时间:2015-06-10 20:17:54

标签: ios objective-c swift uiviewcontroller uinavigationcontroller

我在UINavigationController中嵌入了一个UIViewController。在我的UIViewController里面,我想改变主UIWindow的背景颜色:

let appDelegate  = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.window!.backgroundColor = UIColor.blueColor()

以前的代码在iOS8上工作正常,但在iOS7中,当UIWindow嵌入UINavigationController时,背景颜色没有变化。

如何更改iOS7中UIViewController内部UIWindow的背景颜色?

1 个答案:

答案 0 :(得分:1)

试试这个

    insertPicIntoEditText(getBitmapSpannable(resized_bm, upload_uri));

    private SpannableString getBitmapSpannable(Bitmap pic, String uri_string) {
    SpannableString ss = new SpannableString(uri_string);
    ImageSpan span = new ImageSpan(this, pic);
    ss.setSpan(span, 0, uri_string.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ss;
}

    private void insertPicIntoEditText(SpannableString ss) {
    Editable et = mContentEditor.getText();
    int start = mContentEditor.getSelectionStart();
    et.insert(start, ss);
    et.insert(start + ss.length(), "\n");
    mContentEditor.setText(et);
    mContentEditor.setSelection(start + ss.length() + 1);
}