Skip to content

Instantly share code, notes, and snippets.

class SegmentedControl @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : LinearLayout(context, attrs, defStyleAttr) {
val rect = Rect()
val paint = Paint()
init {
val p = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4f, context.resources.displayMetrics).toInt()
//setPadding(p, p, p, p)
//clipChildren = false
//setWillNotDraw(true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@michaelochs
michaelochs / IrisSegue.mm
Last active May 16, 2018 19:42
This is a segue that does an iris animation like the iOS camera app. Note: The name cameraIris is private API and might lead to rejection!
@implementation IrisSegue
- (void)perform
{
[self.sourceViewController presentViewController:self.destinationViewController animated:NO completion:^{
// don't ask - it just works with two calls to dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSString* shutterAnimationName = @"cameraIris";
/* ----------------------------------------------------------------------------------------------------
Super Form Reset
A couple of things to watch out for:
- IE8: If a text input doesn't have padding on all sides or none the text won't be centered.
- The default border sizes on text inputs in all UAs seem to be slightly different. You're better off using custom borders.
- You NEED to set the font-size and family on all form elements
- Search inputs need to have their appearance reset and the box-sizing set to content-box to match other UAs