1. NSURLConnection
For those who were wondering about this (and I was).
Really, yes, NSURLConnection knows how to handle cookies and does it by default.
You don’t have to manage it by hand.
2. Draw a glow
If you want to reproduce visually the highlight you can see on a UIToolbar button, you can use the following code sniplet :
void evaluate(void *info,const float *in, float *output) {
float x=in[0];
float _C0[4]={1,1,1,0};
float _C1[4]={1,1,1,1};
int i;
float factor;
x = 1 - x;
float c = 0.3;
float b = 1;
factor = exp(-(x - b) * (x - b) / (2 * c * c));
for(i=0;i<4;i++)
output[i] = _C0[i]+factor*(_C1[i]-_C0[i]);
}
- (void) drawRect:(CGRect)rect
{
CGColorSpaceRef space;
CGFunctionRef function;
CGShadingRef shading;
float radius;
float range[8]={0,1,0,1,0,1,0,1};
float domain[2]={0,1};
CGFunctionCallbacks callbacks={0,evaluate,NULL};
CGPoint center;
CGRect glowRect;
CGContextRef context;
glowRect = [self glowRect];
context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM (context, CGRectGetMinX(glowRect),
CGRectGetMinY(glowRect));
CGContextScaleCTM (context, glowRect.size.width, glowRect.size.height);
space = CGColorSpaceCreateDeviceRGB();
function = CGFunctionCreate(self,1,domain,4,range,&callbacks);
radius = 0.5;
center.x = 0.5;
center.y = 0.5;
shading = CGShadingCreateRadial(space, center, 0, center, radius, function, NO, YES);
CGContextDrawShading(context, shading);
CGShadingRelease(shading);
CGColorSpaceRelease(space);
CGContextRestoreGState(context);
}
3. Eliza AI
Do you want emacs doctor back to your iPhone ? You can install our latest app :
