Skip to content

Instantly share code, notes, and snippets.

View MaximST92's full-sized avatar
🤷‍♂️

MaximST92

🤷‍♂️
View GitHub Profile
public static UIImage ImageFromColor(UIColor color, CGRect bounds)
{
UIGraphics.BeginImageContextWithOptions(bounds.Size,false,0);
color.SetFill();
UIGraphics.RectFill(bounds);
var image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
@MaximST92
MaximST92 / gist:443bd70da746448a22d1fbaf874ac9e8
Created April 24, 2017 14:34 — forked from patridge/gist:10499338
Xamarin: get a random color
// Xamarin.iOS (using MonoTouch.UIKit;)
static Random rand = new Random();
public static UIColor GetRandomColor() {
int hue = rand.Next(255);
UIColor color = UIColor.FromHSB(
(hue / 255.0f),
1.0f,
1.0f);
return color;
}
@MaximST92
MaximST92 / Animation Fade
Created February 7, 2017 14:54 — forked from aloisdeniel/Animation Fade
Xamarin.iOS view common animations
public static void Fade (this UIView view, bool isIn, double duration = 0.3, Action onFinished = null)
{
var minAlpha = (nfloat)0.0f;
var maxAlpha = (nfloat)1.0f;
view.Alpha = isIn ? minAlpha : maxAlpha;
view.Transform = CGAffineTransform.MakeIdentity ();
UIView.Animate (duration, 0, UIViewAnimationOptions.CurveEaseInOut,
() => {
view.Alpha = isIn ? maxAlpha : minAlpha;
[Register("PieProgressView")]
public class PieProgressView: UIView
{
private float _pieWidth;
private float _progress;
public float Progress
{
get { return _progress; }