autoresizingmask - UIViewAutoresizingFlexibleLeftMargin with Reference to Superview on iOS -


i'm dynamically adding error icon fields in form shown here:

error icon

i'm generating icon in code, , want position on top-right of superview, can't go want it. screenshot shows how stays on left, should on right.

here's code:

//create image uiimageview *erroricon =[[uiimageview alloc] initwithframe:cgrectmake(-10,-10,23,23)];  //set image file erroricon.image = [uiimage imagenamed:@"error.png"];  //tell image position on top-right (flexible left margin, flexible bottom margin) erroricon.autoresizingmask = uiviewautoresizingflexibleleftmargin | uiviewautoresizingflexiblebottommargin; 

no matter set frame's x value to, can't stick on right.

what doing wrong frame and/or autoresizingmask?

your problem line:

uiimageview *erroricon =      [[uiimageview alloc] initwithframe:cgrectmake(-10,-10,23,23)]; 

that means top left of superview. if isn't want put it, don't put there!

the top right here:

uiimageview *erroricon =      [[uiimageview alloc] initwithframe:         cgrectmake(superview.bounds.size.width-10,-10,23,23)]; 

(for superview substitute reference view superview.)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -