Haruyuki Mohri

毛利春幸のブログです。

TAlphaColor to UIColor(iOS) Converter

UIColor is the color object for iOS.
C++Builder use TAlphaColor.It must be converted.

TAlphaColor to UIColor Converter. Make the function

#include <iOSapi.UIKit.hpp>
//This Convert from TAlphaColor to UIColor
_di_UIColor AlphaColorToUIColor(TAlphaColor&& color)
{
    TAlphaColorRec cr = color;
    return TUIColor::Wrap(TUIColor::OCClass->colorWithRed(cr.R / 255,cr.G / 255,cr.B / 255,cr.A / 255));
}

Try to write a sample code. confirm.

//After creating a UIWindow, to draw a background.
void __fastcall TForm1::Button2Click(TObject *Sender)
{
    _di_UIWindow win_ = TUIWindow::Create();
    win_->setBackgroundColor(AlphaColorToUIColor(TAlphaColorRec::Yellow));
    win_->setHidden(False);
}

By creating a new window, and draw a background in yellow. f:id:mojeld:20160113125321g:plain